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

Method clone

src/MagicString.js:102–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100 }
101
102 clone() {
103 const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
104
105 let originalChunk = this.firstChunk;
106 let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
107
108 while (originalChunk) {
109 cloned.byStart[clonedChunk.start] = clonedChunk;
110 cloned.byEnd[clonedChunk.end] = clonedChunk;
111
112 const nextOriginalChunk = originalChunk.next;
113 const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
114
115 if (nextClonedChunk) {
116 clonedChunk.next = nextClonedChunk;
117 nextClonedChunk.previous = clonedChunk;
118
119 clonedChunk = nextClonedChunk;
120 }
121
122 originalChunk = nextOriginalChunk;
123 }
124
125 cloned.lastChunk = clonedChunk;
126
127 if (this.indentExclusionRanges) {
128 cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
129 }
130
131 cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
132
133 cloned.intro = this.intro;
134 cloned.outro = this.outro;
135
136 return cloned;
137 }
138
139 generateDecodedMap(options) {
140 options = options || {};

Callers 1

snipMethod · 0.95

Calls 1

sliceMethod · 0.45

Tested by

no test coverage detected