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

Method constructor

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

Source from the content-addressed store, hash-verified

79 declare stats: Stats
80
81 constructor(string: string, options: MagicStringOptions = {}) {
82 const chunk = new Chunk(0, string.length, string)
83
84 Object.defineProperties(this, {
85 original: { writable: true, value: string },
86 outro: { writable: true, value: '' },
87 intro: { writable: true, value: '' },
88 firstChunk: { writable: true, value: chunk },
89 lastChunk: { writable: true, value: chunk },
90 lastSearchedChunk: { writable: true, value: chunk },
91 byStart: { writable: true, value: {} },
92 byEnd: { writable: true, value: {} },
93 filename: { writable: true, value: options.filename },
94 indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
95 sourcemapLocations: { writable: true, value: new BitSet() },
96 storedNames: { writable: true, value: {} },
97 indentStr: { writable: true, value: undefined },
98 ignoreList: { writable: true, value: options.ignoreList },
99 offset: { writable: true, value: options.offset || 0 },
100 })
101
102 if (DEBUG) {
103 Object.defineProperty(this, 'stats', { value: new Stats() })
104 }
105
106 this.byStart[0] = chunk
107 this.byEnd[string.length] = chunk
108 }
109
110 /**
111 * 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