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

Method constructor

src/MagicString.ts:173–194  ·  view source on GitHub ↗

* Wraps `string` for editing; every index passed to the editing methods refers to this original string.

(string: string, options: MagicStringOptions = {})

Source from the content-addressed store, hash-verified

171 * Wraps `string` for editing; every index passed to the editing methods refers to this original string.
172 */
173 constructor(string: string, options: MagicStringOptions = {}) {
174 const chunk = new Chunk(0, string.length, string)
175
176 Object.defineProperties(this, {
177 original: { writable: true, value: string },
178 outro: { writable: true, value: '' },
179 intro: { writable: true, value: '' },
180 firstChunk: { writable: true, value: chunk },
181 lastChunk: { writable: true, value: chunk },
182 lastSearchedChunk: { writable: true, value: chunk },
183 byStart: { writable: true, value: new Map<number, Chunk>([[0, chunk]]) },
184 byEnd: { writable: true, value: new Map<number, Chunk>([[string.length, chunk]]) },
185 filename: { writable: true, value: options.filename },
186 indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
187 sourcemapLocations: { writable: true, value: new BitSet() },
188 storedNames: { writable: true, value: new Set<string>() },
189 indentStr: { writable: true, value: undefined },
190 ignoreList: { writable: true, value: options.ignoreList },
191 offset: { writable: true, value: options.offset || 0 },
192 hasMovedChunks: { writable: true, value: false },
193 })
194 }
195
196 /**
197 * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected