Advance one JS char, updating byte offset for UTF-8.
(L: Lexer)
| 144 | |
| 145 | /** Advance one JS char, updating byte offset for UTF-8. */ |
| 146 | function advance(L: Lexer): void { |
| 147 | const c = L.src.charCodeAt(L.i) |
| 148 | L.i++ |
| 149 | if (c < 0x80) { |
| 150 | L.b++ |
| 151 | } else if (c < 0x800) { |
| 152 | L.b += 2 |
| 153 | } else if (c >= 0xd800 && c <= 0xdbff) { |
| 154 | // High surrogate — next char completes the pair, total 4 UTF-8 bytes |
| 155 | L.b += 4 |
| 156 | L.i++ |
| 157 | } else { |
| 158 | L.b += 3 |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | function peek(L: Lexer, off = 0): string { |
| 163 | return L.i + off < L.len ? L.src[L.i + off]! : '' |
no outgoing calls
no test coverage detected