The abbreviated argument list split on its top-level commas.
(args: string)
| 505 | |
| 506 | /** The abbreviated argument list split on its top-level commas. */ |
| 507 | function splitArgs(args: string): string[] { |
| 508 | const out: string[] = []; |
| 509 | let depth = 0; |
| 510 | let current = ''; |
| 511 | for (const ch of args) { |
| 512 | if (ch === '(' || ch === '[' || ch === '{') depth++; |
| 513 | else if (ch === ')' || ch === ']' || ch === '}') depth = Math.max(0, depth - 1); |
| 514 | if (ch === ',' && depth === 0) { |
| 515 | out.push(current.trim()); |
| 516 | current = ''; |
| 517 | continue; |
| 518 | } |
| 519 | current += ch; |
| 520 | } |
| 521 | if (current.trim()) out.push(current.trim()); |
| 522 | return out; |
| 523 | } |
| 524 | |
| 525 | function firstStatusToken(args: string, which: 'first' | 'last'): string { |
| 526 | const parts = splitArgs(args); |
no test coverage detected