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

Method reset

src/MagicString.js:526–555  ·  view source on GitHub ↗
(start, end)

Source from the content-addressed store, hash-verified

524 }
525
526 reset(start, end) {
527 start = start + this.offset;
528 end = end + this.offset;
529
530 if (this.original.length !== 0) {
531 while (start < 0) start += this.original.length;
532 while (end < 0) end += this.original.length;
533 }
534
535 if (start === end) return this;
536
537 if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
538 if (start > end) throw new Error('end must be greater than start');
539
540 if (DEBUG) this.stats.time('reset');
541
542 this._split(start);
543 this._split(end);
544
545 let chunk = this.byStart[start];
546
547 while (chunk) {
548 chunk.reset();
549
550 chunk = end > chunk.end ? this.byStart[chunk.end] : null;
551 }
552
553 if (DEBUG) this.stats.timeEnd('reset');
554 return this;
555 }
556
557 lastChar() {
558 if (this.outro.length) return this.outro[this.outro.length - 1];

Callers

nothing calls this directly

Calls 3

_splitMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected