MCPcopy Index your code
hub / github.com/nodejs/node / SourceMap

Class SourceMap

lib/internal/source_map/source_map.js:126–317  ·  view source on GitHub ↗

* @class * Implements Source Map V3 model. * See https://github.com/google/closure-compiler/wiki/Source-Maps * for format description.

Source from the content-addressed store, hash-verified

124 * for format description.
125 */
126class SourceMap {
127 #payload;
128 #mappings = [];
129 #sources = {};
130 #sourceContentByURL = {};
131 #lineLengths = undefined;
132
133 /**
134 * @param {SourceMapV3} payload
135 */
136 constructor(payload, { lineLengths } = { __proto__: null }) {
137 if (!base64Map) {
138 const base64Digits =
139 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
140 base64Map = {};
141 for (let i = 0; i < base64Digits.length; ++i)
142 base64Map[base64Digits[i]] = i;
143 }
144 this.#payload = cloneSourceMapV3(payload);
145 this.#parseMappingPayload();
146 if (ArrayIsArray(lineLengths) && lineLengths.length) {
147 this.#lineLengths = lineLengths;
148 }
149 }
150
151 /**
152 * @returns {object} raw source map v3 payload.
153 */
154 get payload() {
155 return cloneSourceMapV3(this.#payload);
156 }
157
158 get [kMappings]() {
159 return this.#mappings;
160 }
161
162 /**
163 * @returns {number[] | undefined} line lengths of generated source code
164 */
165 get lineLengths() {
166 if (this.#lineLengths) {
167 return ArrayPrototypeSlice(this.#lineLengths);
168 }
169 return undefined;
170 }
171
172 #parseMappingPayload = () => {
173 if (this.#payload.sections) {
174 this.#parseSections(this.#payload.sections);
175 } else {
176 this.#parseMap(this.#payload, 0, 0);
177 }
178 ArrayPrototypeSort(this.#mappings, compareSourceMapEntry);
179 };
180
181 /**
182 * @param {Array.<SourceMapV3.Section>} sections
183 */

Callers

nothing calls this directly

Calls 1

#parseMapMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…