| 491 | } |
| 492 | |
| 493 | remove(start, end) { |
| 494 | start = start + this.offset; |
| 495 | end = end + this.offset; |
| 496 | |
| 497 | if (this.original.length !== 0) { |
| 498 | while (start < 0) start += this.original.length; |
| 499 | while (end < 0) end += this.original.length; |
| 500 | } |
| 501 | |
| 502 | if (start === end) return this; |
| 503 | |
| 504 | if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds'); |
| 505 | if (start > end) throw new Error('end must be greater than start'); |
| 506 | |
| 507 | if (DEBUG) this.stats.time('remove'); |
| 508 | |
| 509 | this._split(start); |
| 510 | this._split(end); |
| 511 | |
| 512 | let chunk = this.byStart[start]; |
| 513 | |
| 514 | while (chunk) { |
| 515 | chunk.intro = ''; |
| 516 | chunk.outro = ''; |
| 517 | chunk.edit(''); |
| 518 | |
| 519 | chunk = end > chunk.end ? this.byStart[chunk.end] : null; |
| 520 | } |
| 521 | |
| 522 | if (DEBUG) this.stats.timeEnd('remove'); |
| 523 | return this; |
| 524 | } |
| 525 | |
| 526 | reset(start, end) { |
| 527 | start = start + this.offset; |