* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
(start: number, end: number)
| 798 | * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string). |
| 799 | */ |
| 800 | reset(start: number, end: number): this { |
| 801 | start = start + this.offset |
| 802 | end = end + this.offset |
| 803 | |
| 804 | if (this.original.length !== 0) { |
| 805 | while (start < 0) start += this.original.length |
| 806 | while (end < 0) end += this.original.length |
| 807 | } |
| 808 | |
| 809 | if (start === end) |
| 810 | return this |
| 811 | |
| 812 | if (start < 0 || end > this.original.length) { |
| 813 | throw new MagicStringError(`range ${start}–${end} is out of bounds`) |
| 814 | } |
| 815 | if (start > end) { |
| 816 | throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`) |
| 817 | } |
| 818 | |
| 819 | if (DEBUG) |
| 820 | this.stats.time('reset') |
| 821 | |
| 822 | this._split(start) |
| 823 | this._split(end) |
| 824 | |
| 825 | let chunk = this.byStart.get(start) |
| 826 | |
| 827 | while (chunk) { |
| 828 | chunk.reset() |
| 829 | |
| 830 | chunk = end > chunk.end ? this.byStart.get(chunk.end) : null |
| 831 | } |
| 832 | |
| 833 | if (DEBUG) |
| 834 | this.stats.timeEnd('reset') |
| 835 | return this |
| 836 | } |
| 837 | |
| 838 | lastChar(): string { |
| 839 | if (this.outro.length) |