* Split a comment-free specifier list on the commas between specifiers — not * those inside a string name (`"a,b" as c`).
(list: string)
| 2067 | * those inside a string name (`"a,b" as c`). |
| 2068 | */ |
| 2069 | function 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 | |
| 2089 | const SIMPLE_ESCAPES: Record<string, string> = { n: '\n', t: '\t', r: '\r', b: '\b', f: '\f', v: '\v', '0': '\0' }; |
| 2090 |
no test coverage detected