(text: string, i: number)
| 426 | // Tracks only string, escape and nesting state; `JSON.parse` validates the |
| 427 | // rest. Returns the index after the value, or -1. |
| 428 | scanNested(text: string, i: number): number { |
| 429 | if (this.inString) { |
| 430 | i = this.scanString(text, i, this.escape) |
| 431 | if (i === -1) return -1 |
| 432 | this.inString = false |
| 433 | if (this.depth === 0) return i |
| 434 | } |
| 435 | let depth = this.depth |
| 436 | while (i < text.length) { |
| 437 | const c = text.charCodeAt(i++) |
| 438 | if (c === QUOTE) { |
| 439 | i = this.scanString(text, i, false) |
| 440 | if (i === -1) { |
| 441 | this.inString = true |
| 442 | break |
| 443 | } |
| 444 | } else if (c === LBRACKET || c === LBRACE) { |
| 445 | if (++depth > this.config.maxDepth) this.failDepth() |
| 446 | } else if ((c === RBRACKET || c === RBRACE) && --depth === 0) { |
| 447 | this.depth = 0 |
| 448 | return i |
| 449 | } |
| 450 | } |
| 451 | this.depth = depth |
| 452 | return -1 |
| 453 | } |
| 454 | |
| 455 | // Scans string contents from `i`; returns the index after the closing quote, |
| 456 | // or -1 if the string continues into the next chunk, recording `escape` for |
no test coverage detected