* Does what you'd expect.
()
| 189 | * Does what you'd expect. |
| 190 | */ |
| 191 | clone(): this { |
| 192 | const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset }) |
| 193 | |
| 194 | let originalChunk = this.firstChunk |
| 195 | let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()) |
| 196 | |
| 197 | while (originalChunk) { |
| 198 | cloned.byStart[clonedChunk.start] = clonedChunk |
| 199 | cloned.byEnd[clonedChunk.end] = clonedChunk |
| 200 | |
| 201 | const nextOriginalChunk = originalChunk.next |
| 202 | const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone() |
| 203 | |
| 204 | if (nextClonedChunk) { |
| 205 | clonedChunk.next = nextClonedChunk |
| 206 | nextClonedChunk.previous = clonedChunk |
| 207 | |
| 208 | clonedChunk = nextClonedChunk |
| 209 | } |
| 210 | |
| 211 | originalChunk = nextOriginalChunk |
| 212 | } |
| 213 | |
| 214 | cloned.lastChunk = clonedChunk |
| 215 | |
| 216 | if (this.indentExclusionRanges) { |
| 217 | cloned.indentExclusionRanges = this.indentExclusionRanges.slice() as |
| 218 | | ExclusionRange |
| 219 | | ExclusionRange[] |
| 220 | } |
| 221 | |
| 222 | cloned.sourcemapLocations = new BitSet(this.sourcemapLocations) |
| 223 | |
| 224 | cloned.intro = this.intro |
| 225 | cloned.outro = this.outro |
| 226 | |
| 227 | return cloned as this |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. |