MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / lazyImport

Function lazyImport

src/resolution/frameworks/angular-router.ts:238–246  ·  view source on GitHub ↗

`() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member.

(text: string)

Source from the content-addressed store, hash-verified

236
237/** `() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member. */
238function lazyImport(text: string): { spec: string; member: string | null } | null {
239 const imp = /\bimport\s*\(\s*(['"`])([^'"`]+)\1\s*\)/.exec(text);
240 if (!imp) return null;
241 const after = text.slice(imp.index + imp[0].length);
242 const then = /^\s*\.then\s*\(\s*\(?\s*([A-Za-z_$][\w$]*)\s*\)?\s*=>\s*\(?\s*\1\s*\.\s*([A-Za-z_$][\w$]*)/.exec(after);
243 // `async () => (await import('./x')).HomeModule`
244 const awaited = /^\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/.exec(after);
245 return { spec: imp[2]!, member: then ? then[2]! : awaited ? awaited[1]! : null };
246}
247
248function joinPath(segs: readonly string[]): string {
249 return '/' + segs.join('/');

Callers 2

componentRefFunction · 0.85
walkFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected