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

Method _splitChunk

benchmark/data.js:686–700  ·  view source on GitHub ↗
(chunk, index)

Source from the content-addressed store, hash-verified

684 }
685 }
686 _splitChunk(chunk, index) {
687 if (chunk.edited && chunk.content.length) {
688 const loc = getLocator(this.original)(index);
689 throw new Error(
690 `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`,
691 );
692 }
693 const newChunk = chunk.split(index);
694 this.byEnd[index] = chunk;
695 this.byStart[index] = newChunk;
696 this.byEnd[newChunk.end] = newChunk;
697 if (chunk === this.lastChunk) this.lastChunk = newChunk;
698 this.lastSearchedChunk = chunk;
699 return true;
700 }
701 toString() {
702 let str = this.intro;
703 let chunk = this.firstChunk;

Callers 2

indentMethod · 0.95
_splitMethod · 0.95

Calls 2

getLocatorFunction · 0.70
splitMethod · 0.45

Tested by

no test coverage detected