load-source-map
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -5,3 +5,2 @@ 'use strict' | ||
var path = require('path') | ||
var semver = require('semver') | ||
var SourceMapConsumer = require('source-map').SourceMapConsumer | ||
@@ -11,3 +10,3 @@ | ||
var SOURCEMAP_REGEX = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*(?:\*\/)[ \t]*$)/ | ||
var READ_FILE_OPTS = semver.lt(process.version, '0.9.11') ? 'utf8' : {encoding: 'utf8'} | ||
var READ_FILE_OPTS = { encoding: 'utf8' } | ||
@@ -40,11 +39,15 @@ module.exports = function readSourceMap (filename, cb) { | ||
var consumer | ||
try { | ||
consumer = new SourceMapConsumer(sourceMap) | ||
(new SourceMapConsumer(sourceMap)) | ||
.then(function onConsumerReady (consumer) { | ||
return cb(null, consumer) | ||
}, onConsumerError) | ||
} catch (parseErr) { | ||
parseErr.message = 'Error parsing sourcemap for file "' + filename + '":\n' + parseErr.message | ||
return cb(parseErr) | ||
onConsumerError(parseErr) | ||
} | ||
} | ||
return cb(null, consumer) | ||
function onConsumerError (parseErr) { | ||
parseErr.message = 'Error parsing sourcemap for file "' + filename + '":\n' + parseErr.message | ||
return cb(parseErr) | ||
} | ||
@@ -76,3 +79,3 @@ }) | ||
var rawData = data.slice(data.indexOf(',') + 1) | ||
return new Buffer(rawData, 'base64').toString() | ||
return Buffer.from(rawData, 'base64').toString() | ||
} |
{ | ||
"name": "load-source-map", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Reads a source file and extracts a sourcemap for consumption (inline or external)", | ||
"main": "lib/index.js", | ||
"engines": { | ||
"node": ">= 8" | ||
}, | ||
"scripts": { | ||
"test": "tape test/test.js && standard", | ||
"prepublish": "in-publish && npm test || not-in-publish", | ||
"prepublishOnly": "npm test", | ||
"coverage": "nyc --reporter text --reporter lcov tape test/test.js" | ||
@@ -26,10 +29,8 @@ }, | ||
"dependencies": { | ||
"in-publish": "^2.0.0", | ||
"semver": "^5.3.0", | ||
"source-map": "^0.5.6" | ||
"source-map": "^0.7.3" | ||
}, | ||
"devDependencies": { | ||
"nyc": "^10.2.0", | ||
"standard": "^9.0.2", | ||
"tape": "^4.6.3" | ||
"nyc": "^15.1.0", | ||
"standard": "^14.3.4", | ||
"tape": "^5.0.1" | ||
}, | ||
@@ -36,0 +37,0 @@ "standard": { |
@@ -21,4 +21,4 @@ 'use strict' | ||
var generated = {line: 30, column: 13} | ||
var expected = {line: 15, column: 9, name: 'setState', source: '../src/example.js'} | ||
var generated = { line: 30, column: 13 } | ||
var expected = { line: 15, column: 9, name: 'setState', source: '../src/example.js' } | ||
t.deepEqual(sourcemap.originalPositionFor(generated), expected, 'should have correct source mapping') | ||
@@ -33,4 +33,4 @@ t.end() | ||
var generated = {line: 30, column: 13} | ||
var expected = {line: 15, column: 9, name: 'setState', source: '../src/example.js'} | ||
var generated = { line: 30, column: 13 } | ||
var expected = { line: 15, column: 9, name: 'setState', source: '../src/example.js' } | ||
t.deepEqual(sourcemap.originalPositionFor(generated), expected, 'should have correct source mapping') | ||
@@ -37,0 +37,0 @@ t.end() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
267
19049
15
+ Addedsource-map@0.7.4(transitive)
- Removedin-publish@^2.0.0
- Removedsemver@^5.3.0
- Removedin-publish@2.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsource-map@0.5.7(transitive)
Updatedsource-map@^0.7.3