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

Function splitSpecifierList

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

* Split a comment-free specifier list on the commas between specifiers — not * those inside a string name (`"a,b" as c`).

(list: string)

Source from the content-addressed store, hash-verified

2067 * those inside a string name (`"a,b" as c`).
2068 */
2069function splitSpecifierList(list: string): string[] {
2070 const out: string[] = [];
2071 let start = 0;
2072 let quote: string | null = null;
2073 for (let i = 0; i < list.length; i++) {
2074 const ch = list[i]!;
2075 if (quote !== null) {
2076 if (ch === '\\') i++;
2077 else if (ch === quote) quote = null;
2078 } else if (ch === '"' || ch === "'") {
2079 quote = ch;
2080 } else if (ch === ',') {
2081 out.push(list.slice(start, i));
2082 start = i + 1;
2083 }
2084 }
2085 out.push(list.slice(start));
2086 return out;
2087}
2088
2089const SIMPLE_ESCAPES: Record<string, string> = { n: '\n', t: '\t', r: '\r', b: '\b', f: '\f', v: '\v', '0': '\0' };
2090

Callers 2

extractJSImportsFunction · 0.85
extractReExportsFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected