* Where the expression starting at `from` ends: a `;` or `,` outside any * bracket, or the words `as` / `let` that open the next microsyntax binding.
(text: string, from: number)
| 331 | * bracket, or the words `as` / `let` that open the next microsyntax binding. |
| 332 | */ |
| 333 | function expressionEnd(text: string, from: number): number { |
| 334 | let depth = 0; |
| 335 | for (let i = from; i < text.length; i++) { |
| 336 | const ch = text[i]!; |
| 337 | if (ch === '"' || ch === "'" || ch === '`') { |
| 338 | const end = skipString(text, i); |
| 339 | if (end < 0) return text.length; |
| 340 | i = end; |
| 341 | continue; |
| 342 | } |
| 343 | if (ch === '(' || ch === '[' || ch === '{') depth++; |
| 344 | else if (ch === ')' || ch === ']' || ch === '}') depth--; |
| 345 | else if (depth === 0 && (ch === ';' || ch === ',')) return i; |
| 346 | else if (depth === 0 && isBlank(text[i - 1]) && /^(?:as|let)(?![\w$])/.test(text.slice(i, i + 4))) return i; |
| 347 | } |
| 348 | return text.length; |
| 349 | } |
| 350 | |
| 351 | /** `text` split at each `;` outside brackets and strings, with each part's offset. */ |
| 352 | function topLevelParts(text: string): Array<{ at: number; text: string }> { |
no test coverage detected