Skip to content

Instantly share code, notes, and snippets.

@Daniel15
Created November 30, 2015 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daniel15/4bdb15836bfd960c2956 to your computer and use it in GitHub Desktop.
Save Daniel15/4bdb15836bfd960c2956 to your computer and use it in GitHub Desktop.
Modify source map to move everything down by five lines
var DOCBLOCK_LINES = 5;
var first = new sourceMap.SourceMapConsumer(input);
var generator = new sourceMap.SourceMapGenerator({
file: first.file,
});
first.eachMapping(function(mapping) {
generator.addMapping({
generated: {
column: mapping.generatedColumn,
line: mapping.generatedLine + DOCBLOCK_LINES,
},
original: {
column: mapping.originalColumn,
line: mapping.originalLine,
},
source: mapping.source
});
});
first.sources.forEach(function(sourceFile) {
generator.setSourceContent(sourceFile, first.sourceContentFor(sourceFile));
});
console.log(generator.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment