(inner: string, angle: boolean)
| 320 | } |
| 321 | |
| 322 | function splitTopLevel(inner: string, angle: boolean): string[] { |
| 323 | const out: string[] = []; |
| 324 | let depth = 0; |
| 325 | let start = 0; |
| 326 | for (let i = 0; i < inner.length; i++) { |
| 327 | const c = inner[i]!; |
| 328 | if (isOpener(c, angle)) depth++; |
| 329 | else if (isCloser(c, angle, inner[i - 1])) depth--; |
| 330 | else if (c === ',' && depth === 0) { |
| 331 | out.push(inner.slice(start, i)); |
| 332 | start = i + 1; |
| 333 | } |
| 334 | } |
| 335 | out.push(inner.slice(start)); |
| 336 | return out; |
| 337 | } |
| 338 | |
| 339 | function isOpener(c: string, angle: boolean): boolean { |
| 340 | return c === '[' || c === '(' || (angle && c === '<'); |
no test coverage detected