* The index of the brace closing the block at `open`, or -1. A quote right * after a word is an apostrophe in JSX text (` Don't `), not a string.
(safe: string, open: number)
| 2342 | * after a word is an apostrophe in JSX text (`<p>Don't</p>`), not a string. |
| 2343 | */ |
| 2344 | function blockEnd(safe: string, open: number): number { |
| 2345 | let depth = 0; |
| 2346 | for (let i = open; i < safe.length; i++) { |
| 2347 | if (opensString(safe, i)) { |
| 2348 | const end = skipString(safe, i); |
| 2349 | if (end < 0) return -1; |
| 2350 | i = end; |
| 2351 | continue; |
| 2352 | } |
| 2353 | const ch = safe[i]!; |
| 2354 | if (ch === '{' || ch === '(' || ch === '[') depth++; |
| 2355 | else if ((ch === '}' || ch === ')' || ch === ']') && --depth === 0) return i; |
| 2356 | } |
| 2357 | return -1; |
| 2358 | } |
| 2359 | |
| 2360 | /** True for a quote that opens a string or template, not an apostrophe in JSX text. */ |
| 2361 | function opensString(safe: string, i: number): boolean { |
no test coverage detected