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