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

Method clone

benchmark/data.js:328–352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

326 return this;
327 }
328 clone() {
329 const cloned = new MagicString(this.original, { filename: this.filename });
330 let originalChunk = this.firstChunk;
331 let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
332 while (originalChunk) {
333 cloned.byStart[clonedChunk.start] = clonedChunk;
334 cloned.byEnd[clonedChunk.end] = clonedChunk;
335 const nextOriginalChunk = originalChunk.next;
336 const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
337 if (nextClonedChunk) {
338 clonedChunk.next = nextClonedChunk;
339 nextClonedChunk.previous = clonedChunk;
340 clonedChunk = nextClonedChunk;
341 }
342 originalChunk = nextOriginalChunk;
343 }
344 cloned.lastChunk = clonedChunk;
345 if (this.indentExclusionRanges) {
346 cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
347 }
348 cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
349 cloned.intro = this.intro;
350 cloned.outro = this.outro;
351 return cloned;
352 }
353 generateDecodedMap(options) {
354 options = options || {};
355 const sourceIndex = 0;

Callers 1

snipMethod · 0.95

Calls 2

cloneMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected