* Parses a chunk of data and calls the corresponding callbacks. * @param chunk Chunk to parse.
(chunk: string)
| 771 | * @param chunk Chunk to parse. |
| 772 | */ |
| 773 | write(chunk: string): void { |
| 774 | if (this.ended) { |
| 775 | this.cbs.onerror?.(new Error(".write() after done!")); |
| 776 | return; |
| 777 | } |
| 778 | |
| 779 | this.buffers.push(chunk); |
| 780 | if (this.tokenizer.running) { |
| 781 | this.tokenizer.write(chunk); |
| 782 | this.writeIndex++; |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Parses the end of the buffer and clears the stack, calls onend. |