* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
(start: number, end: number)
| 760 | * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string). |
| 761 | */ |
| 762 | reset(start: number, end: number): this { |
| 763 | start = start + this.offset |
| 764 | end = end + this.offset |
| 765 | |
| 766 | if (this.original.length !== 0) { |
| 767 | while (start < 0) start += this.original.length |
| 768 | while (end < 0) end += this.original.length |
| 769 | } |
| 770 | |
| 771 | if (start === end) |
| 772 | return this |
| 773 | |
| 774 | if (start < 0 || end > this.original.length) |
| 775 | throw new Error('Character is out of bounds') |
| 776 | if (start > end) |
| 777 | throw new Error(`end must be greater than start (start: ${start}, end: ${end})`) |
| 778 | |
| 779 | if (DEBUG) |
| 780 | this.stats.time('reset') |
| 781 | |
| 782 | this._split(start) |
| 783 | this._split(end) |
| 784 | |
| 785 | let chunk = this.byStart.get(start) |
| 786 | |
| 787 | while (chunk) { |
| 788 | chunk.reset() |
| 789 | |
| 790 | chunk = end > chunk.end ? this.byStart.get(chunk.end) : null |
| 791 | } |
| 792 | |
| 793 | if (DEBUG) |
| 794 | this.stats.timeEnd('reset') |
| 795 | return this |
| 796 | } |
| 797 | |
| 798 | lastChar(): string { |
| 799 | if (this.outro.length) |