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

Method constructor

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

Source from the content-addressed store, hash-verified

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