(s: string, at: number)
| 38 | |
| 39 | /** The index of the quote closing the string or template opened at `at`, or -1. */ |
| 40 | export function skipString(s: string, at: number): number { |
| 41 | const quote = s[at]!; |
| 42 | for (let i = at + 1; i < s.length; i++) { |
| 43 | const ch = s[i]!; |
| 44 | if (ch === '\\') { |
| 45 | i++; |
| 46 | continue; |
| 47 | } |
| 48 | if (ch === quote) return i; |
| 49 | if (quote === '`' && ch === '$' && s[i + 1] === '{') { |
| 50 | const end = matchBracket(s, i + 1); |
| 51 | if (end < 0) return -1; |
| 52 | i = end; |
| 53 | } |
| 54 | } |
| 55 | return -1; |
| 56 | } |
| 57 | |
| 58 | /** Each `{…}` written directly in `[from, to)`, as its own extent. */ |
| 59 | export function* topLevelObjects(s: string, from: number, to: number): Generator<{ start: number; end: number }> { |
no test coverage detected