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