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

Method generateDecodedMap

benchmark/data.js:353–384  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

351 return cloned;
352 }
353 generateDecodedMap(options) {
354 options = options || {};
355 const sourceIndex = 0;
356 const names = Object.keys(this.storedNames);
357 const mappings = new Mappings(options.hires);
358 const locate = getLocator(this.original);
359 if (this.intro) {
360 mappings.advance(this.intro);
361 }
362 this.firstChunk.eachNext((chunk) => {
363 const loc = locate(chunk.start);
364 if (chunk.intro.length) mappings.advance(chunk.intro);
365 if (chunk.edited) {
366 mappings.addEdit(
367 sourceIndex,
368 chunk.content,
369 loc,
370 chunk.storeName ? names.indexOf(chunk.original) : -1,
371 );
372 } else {
373 mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
374 }
375 if (chunk.outro.length) mappings.advance(chunk.outro);
376 });
377 return {
378 file: options.file ? options.file.split(/[/\\]/).pop() : null,
379 sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
380 sourcesContent: options.includeContent ? [this.original] : [null],
381 names,
382 mappings: mappings.raw,
383 };
384 }
385 generateMap(options) {
386 return new SourceMap(this.generateDecodedMap(options));
387 }

Callers 1

generateMapMethod · 0.95

Calls 7

advanceMethod · 0.95
addEditMethod · 0.95
addUneditedChunkMethod · 0.95
getLocatorFunction · 0.70
getRelativePathFunction · 0.70
eachNextMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected