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