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

Method _split

src/MagicString.js:661–680  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

659 }
660
661 _split(index) {
662 if (this.byStart[index] || this.byEnd[index]) return;
663
664 if (DEBUG) this.stats.time('_split');
665
666 let chunk = this.lastSearchedChunk;
667 let previousChunk = chunk;
668 const searchForward = index > chunk.end;
669
670 while (chunk) {
671 if (chunk.contains(index)) return this._splitChunk(chunk, index);
672
673 chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
674
675 // Prevent infinite loop (e.g. via empty chunks, where start === end)
676 if (chunk === previousChunk) return;
677
678 previousChunk = chunk;
679 }
680 }
681
682 _splitChunk(chunk, index) {
683 if (chunk.edited && chunk.content.length) {

Callers 8

appendLeftMethod · 0.95
appendRightMethod · 0.95
moveMethod · 0.95
updateMethod · 0.95
prependLeftMethod · 0.95
prependRightMethod · 0.95
removeMethod · 0.95
resetMethod · 0.95

Calls 3

_splitChunkMethod · 0.95
timeMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected