Socket
Socket
Sign inDemoInstall

istanbul-lib-source-maps

Package Overview
Dependencies
2
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4

39

lib/map-store.js

@@ -10,3 +10,2 @@ /*

transformer = require('./transformer'),
converter = require('convert-source-map'),
SMC = require('source-map').SourceMapConsumer;

@@ -23,7 +22,19 @@

* @param transformedFilePath - the file path for which the source map is valid
* @param sourceMapUrl - the source map URL
* @param sourceMapUrl - the source map URL, **not** a comment
*/
MapStore.prototype.registerURL = function (transformedFilePath, sourceMapUrl) {
if (sourceMapUrl.indexOf('data') === 0) {
this.data[transformedFilePath] = converter.fromComment(sourceMapUrl).toObject();
var d = 'data:',
b64 = 'base64,',
pos;
if (sourceMapUrl.length > d.length && sourceMapUrl.substring(0, d.length) === d) {
pos = sourceMapUrl.indexOf(b64);
if (pos > 0) {
this.data[transformedFilePath] = {
type: 'encoded',
data: sourceMapUrl.substring(pos + b64.length)
};
} else {
console.error('Unable to interpret source map URL: ', sourceMapUrl);
}
return;

@@ -33,3 +44,3 @@ }

file = path.resolve(dir, sourceMapUrl);
this.data[transformedFilePath] = { file: file };
this.data[transformedFilePath] = { type: 'file', data: file };
};

@@ -42,3 +53,7 @@ /**

MapStore.prototype.registerMap = function (transformedFilePath, sourceMap) {
this.data[transformedFilePath] = converter.fromObject(sourceMap);
if (sourceMap.version) {
this.data[transformedFilePath] = { type: 'object', data: sourceMap };
} else {
console.error('Invalid source map object', sourceMap);
}
};

@@ -53,5 +68,11 @@

}
var obj = that.data[filePath];
if (obj.file) {
return new SMC(JSON.parse(fs.readFileSync(obj.file, 'utf8')));
var d = that.data[filePath],
obj;
if (d.type === 'file') {
obj = JSON.parse(fs.readFileSync(d.data, 'utf8'));
} else if (d.type === 'encoded') {
obj = JSON.parse(new Buffer(d.data, 'base64').toString());
} else {
obj = d.data;
}

@@ -58,0 +79,0 @@ return new SMC(obj);

{
"name": "istanbul-lib-source-maps",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"description": "Source maps support for istanbul",

@@ -14,3 +14,2 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

"dependencies": {
"convert-source-map": "^1.1.2",
"istanbul-lib-coverage": "^1.0.0-alpha.0",

@@ -17,0 +16,0 @@ "source-map": "^0.5.3"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc