| 275 | storeName: false, |
| 276 | }; |
| 277 | class MagicString { |
| 278 | constructor(string, options = {}) { |
| 279 | const chunk = new Chunk(0, string.length, string); |
| 280 | Object.defineProperties(this, { |
| 281 | original: { writable: true, value: string }, |
| 282 | outro: { writable: true, value: '' }, |
| 283 | intro: { writable: true, value: '' }, |
| 284 | firstChunk: { writable: true, value: chunk }, |
| 285 | lastChunk: { writable: true, value: chunk }, |
| 286 | lastSearchedChunk: { writable: true, value: chunk }, |
| 287 | byStart: { writable: true, value: {} }, |
| 288 | byEnd: { writable: true, value: {} }, |
| 289 | filename: { writable: true, value: options.filename }, |
| 290 | indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, |
| 291 | sourcemapLocations: { writable: true, value: new BitSet() }, |
| 292 | storedNames: { writable: true, value: {} }, |
| 293 | indentStr: { writable: true, value: guessIndent(string) }, |
| 294 | }); |
| 295 | this.byStart[0] = chunk; |
| 296 | this.byEnd[string.length] = chunk; |
| 297 | } |
| 298 | addSourcemapLocation(char) { |
| 299 | this.sourcemapLocations.add(char); |
| 300 | } |
| 301 | append(content) { |
| 302 | if (typeof content !== 'string') throw new TypeError('outro content must be a string'); |
| 303 | this.outro += content; |
| 304 | return this; |
| 305 | } |
| 306 | appendLeft(index, content) { |
| 307 | if (typeof content !== 'string') throw new TypeError('inserted content must be a string'); |
| 308 | this._split(index); |
| 309 | const chunk = this.byEnd[index]; |
| 310 | if (chunk) { |
| 311 | chunk.appendLeft(content); |
| 312 | } else { |
| 313 | this.intro += content; |
| 314 | } |
| 315 | return this; |
| 316 | } |
| 317 | appendRight(index, content) { |
| 318 | if (typeof content !== 'string') throw new TypeError('inserted content must be a string'); |
| 319 | this._split(index); |
| 320 | const chunk = this.byStart[index]; |
| 321 | if (chunk) { |
| 322 | chunk.appendRight(content); |
| 323 | } else { |
| 324 | this.outro += content; |
| 325 | } |
| 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; |
nothing calls this directly
no outgoing calls
no test coverage detected