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

Function parseSpecifier

src/resolution/import-resolver.ts:2208–2218  ·  view source on GitHub ↗

* One `{ … }` import/export specifier — `a`, `a as b`, `"a-b" as c`, and the * same with TypeScript's inline `type` modifier (`type a`, `type a as b`) — as * the name it takes from the module and the name it binds (Flow's `typeof` * modifier likewise). `type` alone, or `type as t`, is a specifier

(raw: string)

Source from the content-addressed store, hash-verified

2206 * split by {@link splitSpecifierList}.
2207 */
2208function parseSpecifier(raw: string): { imported: string; local: string } | null {
2209 const item = raw.trim();
2210 const alias = SPECIFIER_ALIAS.exec(item);
2211 if (alias) return { imported: unquoteSpecifier(alias[1]!), local: unquoteSpecifier(alias[2]!) };
2212 const plain = SPECIFIER_PLAIN.exec(item);
2213 if (plain) {
2214 const name = unquoteSpecifier(plain[1]!);
2215 return { imported: name, local: name };
2216 }
2217 return null;
2218}
2219
2220/**
2221 * Extract JS/TS import mappings

Callers 2

extractJSImportsFunction · 0.85
extractReExportsFunction · 0.85

Calls 2

unquoteSpecifierFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected