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

Method constructor

src/MagicString.ts:172–197  ·  view source on GitHub ↗
(string: string, options: MagicStringOptions = {})

Source from the content-addressed store, hash-verified

170 declare hasMovedChunks: boolean
171
172 constructor(string: string, options: MagicStringOptions = {}) {
173 const chunk = new Chunk(0, string.length, string)
174
175 Object.defineProperties(this, {
176 original: { writable: true, value: string },
177 outro: { writable: true, value: '' },
178 intro: { writable: true, value: '' },
179 firstChunk: { writable: true, value: chunk },
180 lastChunk: { writable: true, value: chunk },
181 lastSearchedChunk: { writable: true, value: chunk },
182 byStart: { writable: true, value: new Map<number, Chunk>([[0, chunk]]) },
183 byEnd: { writable: true, value: new Map<number, Chunk>([[string.length, chunk]]) },
184 filename: { writable: true, value: options.filename },
185 indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
186 sourcemapLocations: { writable: true, value: new BitSet() },
187 storedNames: { writable: true, value: {} },
188 indentStr: { writable: true, value: undefined },
189 ignoreList: { writable: true, value: options.ignoreList },
190 offset: { writable: true, value: options.offset || 0 },
191 hasMovedChunks: { writable: true, value: false },
192 })
193
194 if (DEBUG) {
195 Object.defineProperty(this, 'stats', { value: new Stats() })
196 }
197 }
198
199 /**
200 * 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