MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / remove

Method remove

benchmark/data.js:581–597  ·  view source on GitHub ↗
(start, end)

Source from the content-addressed store, hash-verified

579 return this;
580 }
581 remove(start, end) {
582 while (start < 0) start += this.original.length;
583 while (end < 0) end += this.original.length;
584 if (start === end) return this;
585 if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
586 if (start > end) throw new Error('end must be greater than start');
587 this._split(start);
588 this._split(end);
589 let chunk = this.byStart[start];
590 while (chunk) {
591 chunk.intro = '';
592 chunk.outro = '';
593 chunk.edit('');
594 chunk = end > chunk.end ? this.byStart[chunk.end] : null;
595 }
596 return this;
597 }
598 lastChar() {
599 if (this.outro.length) return this.outro[this.outro.length - 1];
600 let chunk = this.lastChunk;

Callers 1

snipMethod · 0.45

Calls 2

_splitMethod · 0.95
editMethod · 0.45

Tested by

no test coverage detected