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

Method split

benchmark/data.js:76–96  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

74 this.intro = content + this.intro;
75 }
76 split(index) {
77 const sliceIndex = index - this.start;
78 const originalBefore = this.original.slice(0, sliceIndex);
79 const originalAfter = this.original.slice(sliceIndex);
80 this.original = originalBefore;
81 const newChunk = new Chunk(index, this.end, originalAfter);
82 newChunk.outro = this.outro;
83 this.outro = '';
84 this.end = index;
85 if (this.edited) {
86 newChunk.edit('', false);
87 this.content = '';
88 } else {
89 this.content = originalBefore;
90 }
91 newChunk.next = this.next;
92 if (newChunk.next) newChunk.next.previous = newChunk;
93 newChunk.previous = this;
94 this.next = newChunk;
95 return newChunk;
96 }
97 toString() {
98 return this.intro + this.content + this.outro;
99 }

Callers 9

trimEndMethod · 0.95
trimStartMethod · 0.95
guessIndentFunction · 0.45
getRelativePathFunction · 0.45
getLocatorFunction · 0.45
advanceMethod · 0.45
generateDecodedMapMethod · 0.45
_splitChunkMethod · 0.45
generateDecodedMapMethod · 0.45

Calls 2

editMethod · 0.95
sliceMethod · 0.45

Tested by

no test coverage detected