(text: string, i: number, escape: boolean)
| 456 | // or -1 if the string continues into the next chunk, recording `escape` for |
| 457 | // `scanNested` to resume with. |
| 458 | scanString(text: string, i: number, escape: boolean): number { |
| 459 | let plain = 0 |
| 460 | while (i < text.length) { |
| 461 | const c = text.charCodeAt(i++) |
| 462 | if (escape) { |
| 463 | escape = false |
| 464 | } else if (c === BACKSLASH) { |
| 465 | escape = true |
| 466 | } else if (c === QUOTE) { |
| 467 | return i |
| 468 | } else if (++plain === 16) { |
| 469 | // A long string: jump to the next quote or backslash. |
| 470 | if (this.quote < i) this.quote = indexOf(text, "\"", i) |
| 471 | if (this.backslash < i) this.backslash = indexOf(text, "\\", i) |
| 472 | i = Math.min(this.quote, this.backslash) |
| 473 | plain = 0 |
| 474 | } |
| 475 | } |
| 476 | this.escape = escape |
| 477 | return -1 |
| 478 | } |
| 479 | |
| 480 | // Parses the elements from `i` up to the last comma or closing bracket at |
| 481 | // the array's level with one `JSON.parse`. Wrapped in brackets, that text |
no test coverage detected