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

Method move

benchmark/data-min.js:388–411  ·  view source on GitHub ↗
(t, e, n)

Source from the content-addressed store, hash-verified

386 );
387 }
388 move(t, e, n) {
389 if (n >= t && n <= e) throw new Error('Cannot move a selection inside itself');
390 (this._split(t), this._split(e), this._split(n));
391 const i = this.byStart[t],
392 r = this.byEnd[e],
393 s = i.previous,
394 h = r.next,
395 o = this.byStart[n];
396 if (!o && r === this.lastChunk) return this;
397 const a = o ? o.previous : this.lastChunk;
398 return (
399 s && (s.next = h),
400 h && (h.previous = s),
401 a && (a.next = i),
402 o && (o.previous = r),
403 i.previous || (this.firstChunk = r.next),
404 r.next || ((this.lastChunk = i.previous), (this.lastChunk.next = null)),
405 (i.previous = a),
406 (r.next = o || null),
407 a || (this.firstChunk = i),
408 o || (this.lastChunk = r),
409 this
410 );
411 }
412 overwrite(t, e, n, i) {
413 if (typeof n != 'string') throw new TypeError('replacement content must be a string');
414 for (; t < 0; ) t += this.original.length;

Callers 2

Bundle.test.tsFile · 0.45

Calls 1

_splitMethod · 0.95

Tested by

no test coverage detected