* Parses the end of the buffer and clears the stack, calls onend. * @param chunk Optional final chunk to parse.
(chunk?: string)
| 788 | * @param chunk Optional final chunk to parse. |
| 789 | */ |
| 790 | end(chunk?: string): void { |
| 791 | if (this.ended) { |
| 792 | this.cbs.onerror?.(new Error(".end() after done!")); |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | if (chunk) this.write(chunk); |
| 797 | this.ended = true; |
| 798 | this.tokenizer.end(); |
| 799 | } |
| 800 | |
| 801 | /** |
| 802 | * Pauses parsing. The parser won't emit events until `resume` is called. |