(chunk: string, force = false)
| 1504 | } |
| 1505 | |
| 1506 | private consume(chunk: string, force = false): void { |
| 1507 | this.received += chunk.length |
| 1508 | if (this.pending !== undefined) { |
| 1509 | if (!force && this.scanner.scan(chunk, 0) === -1) { |
| 1510 | this.pending.push(chunk) |
| 1511 | this.pendingLength += chunk.length |
| 1512 | // Joins runs of chunks, so that a token split into many tiny chunks |
| 1513 | // does not take an array slot for each |
| 1514 | if (++this.pendingAdded === pendingRun) { |
| 1515 | this.pending.push(this.pending.splice(-pendingRun).join("")) |
| 1516 | this.pendingAdded = 0 |
| 1517 | } |
| 1518 | this.checkPending() |
| 1519 | return |
| 1520 | } |
| 1521 | // Joining makes a flat string, which V8 reads faster than the rope that |
| 1522 | // concatenation makes |
| 1523 | this.pending.push(chunk) |
| 1524 | this.load(this.pending.join(""), this.pendingStart) |
| 1525 | this.pending = undefined |
| 1526 | } else { |
| 1527 | this.load(chunk, this.received - chunk.length) |
| 1528 | } |
| 1529 | this.parse(false) |
| 1530 | } |
| 1531 | |
| 1532 | private load(buf: string, base: number): void { |
| 1533 | this.buf = buf |
no test coverage detected