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

Function splitSpecifierList

src/resolution/import-resolver.ts:2150–2168  ·  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

2148 * those inside a string name (`"a,b" as c`).
2149 */
2150function splitSpecifierList(list: string): string[] {
2151 const out: string[] = [];
2152 let start = 0;
2153 let quote: string | null = null;
2154 for (let i = 0; i < list.length; i++) {
2155 const ch = list[i]!;
2156 if (quote !== null) {
2157 if (ch === '\\') i++;
2158 else if (ch === quote) quote = null;
2159 } else if (ch === '"' || ch === "'") {
2160 quote = ch;
2161 } else if (ch === ',') {
2162 out.push(list.slice(start, i));
2163 start = i + 1;
2164 }
2165 }
2166 out.push(list.slice(start));
2167 return out;
2168}
2169
2170const SIMPLE_ESCAPES: Record<string, string> = { n: '\n', t: '\t', r: '\r', b: '\b', f: '\f', v: '\v', '0': '\0' };
2171

Callers 2

extractJSImportsFunction · 0.85
extractReExportsFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected