* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
(start: number, end: number)
| 1000 | * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string). |
| 1001 | */ |
| 1002 | reset(start: number, end: number): this { |
| 1003 | start = start + this.offset |
| 1004 | end = end + this.offset |
| 1005 | |
| 1006 | if (this.original.length !== 0) { |
| 1007 | if (start < 0) |
| 1008 | start = Math.max(0, start + this.original.length) |
| 1009 | if (end < 0) |
| 1010 | end = Math.max(0, end + this.original.length) |
| 1011 | } |
| 1012 | |
| 1013 | if (start === end) |
| 1014 | return this |
| 1015 | |
| 1016 | if (start < 0 || end > this.original.length) { |
| 1017 | throw new MagicStringError(`range ${start}–${end} is out of bounds`) |
| 1018 | } |
| 1019 | if (start > end) { |
| 1020 | throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`) |
| 1021 | } |
| 1022 | |
| 1023 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 1024 | if (DEBUG) |
| 1025 | this.stats.time('reset') |
| 1026 | |
| 1027 | this._split(start) |
| 1028 | this._split(end) |
| 1029 | |
| 1030 | let chunk = this.byStart.get(start) |
| 1031 | |
| 1032 | while (chunk) { |
| 1033 | chunk.reset() |
| 1034 | |
| 1035 | chunk = end > chunk.end ? this.byStart.get(chunk.end) : null |
| 1036 | } |
| 1037 | |
| 1038 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 1039 | if (DEBUG) |
| 1040 | this.stats.timeEnd('reset') |
| 1041 | return this |
| 1042 | } |
| 1043 | |
| 1044 | lastChar(): string { |
| 1045 | if (this.outro.length) |