diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/merge-source-map/index.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) | |
download | wallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz |
update packages
Diffstat (limited to 'node_modules/merge-source-map/index.js')
-rw-r--r-- | node_modules/merge-source-map/index.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/node_modules/merge-source-map/index.js b/node_modules/merge-source-map/index.js index ef208d99c..2867fb7f5 100644 --- a/node_modules/merge-source-map/index.js +++ b/node_modules/merge-source-map/index.js @@ -13,11 +13,8 @@ module.exports = merge * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined */ function merge(oldMap, newMap) { - - if (!oldMap) - return newMap - if (!newMap) - return oldMap + if (!oldMap) return newMap + if (!newMap) return oldMap var oldMapConsumer = new SourceMapConsumer(oldMap) var newMapConsumer = new SourceMapConsumer(newMap) @@ -25,15 +22,16 @@ function merge(oldMap, newMap) { // iterate on new map and overwrite original position of new map with one of old map newMapConsumer.eachMapping(function(m) { - // pass when `originalLine` is null. // It occurs in case that the node does not have origin in original code. - if (m.originalLine == null) - return + if (m.originalLine == null) return + + var origPosInOldMap = oldMapConsumer.originalPositionFor({ + line: m.originalLine, + column: m.originalColumn + }) - var origPosInOldMap = oldMapConsumer.originalPositionFor({line: m.originalLine, column: m.originalColumn}) - if (origPosInOldMap.source == null) - return + if (origPosInOldMap.source == null) return mergedMapGenerator.addMapping({ original: { @@ -49,13 +47,19 @@ function merge(oldMap, newMap) { }) }) - var mergedMap = JSON.parse(mergedMapGenerator.toString()) - - mergedMap.sourcesContent = mergedMap.sources.map(function (source) { - return oldMapConsumer.sourceContentFor(source) + var consumers = [oldMapConsumer, newMapConsumer] + consumers.forEach(function(consumer) { + consumer.sources.forEach(function(sourceFile) { + mergedMapGenerator._sources.add(sourceFile) + var sourceContent = consumer.sourceContentFor(sourceFile) + if (sourceContent != null) { + mergedMapGenerator.setSourceContent(sourceFile, sourceContent) + } + }) }) - mergedMap.sourceRoot = oldMap.sourceRoot + mergedMapGenerator._sourceRoot = oldMap.sourceRoot + mergedMapGenerator._file = oldMap.file - return mergedMap + return JSON.parse(mergedMapGenerator.toString()) } |