Socket
Socket
Sign inDemoInstall

sorcery

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorcery - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

42

lib/Node.js

@@ -52,2 +52,8 @@ var path = require( 'path' ),

}
}).then( function () {
if ( !self.isOriginalSource ) {
return self;
}
return null;
});

@@ -71,3 +77,6 @@ },

self.sources = self.map.sources.map( function ( source ) {
return new Node( resolveSourcePath( self, source ) )._loadSync();
var node = new Node( resolveSourcePath( self, source ) );
node._loadSync();
return node;
});

@@ -78,3 +87,3 @@

return this;
return !this.isOriginalSource ? this : null;
},

@@ -144,6 +153,6 @@

sources: sources.map( function ( source ) {
return getRelativePath( self.file, source );
return getRelativePath( options.base || self.file, source );
}),
sourcesContent: sources.map( function ( source ) {
return options.includeContent ? self.sourcesContentByPath[ source ] : null;
return includeContent ? self.sourcesContentByPath[ source ] : null;
}),

@@ -199,2 +208,27 @@ names: names,

}
},
write: function ( dest, options ) {
var map, url, index, content;
options = options || {};
dest = path.resolve( dest );
map = this.apply({
includeContent: options.includeContent,
base: dest
});
url = options.inline ? map.toUrl() : path.basename( dest ) + '.map';
index = this.content.lastIndexOf( 'sourceMappingURL=' ) + 17;
content = this.content.substr( 0, index ) + this.content.substring( index ).replace( /^\S+/, url );
promises = [ sander.writeFile( dest, content ) ];
if ( !options.inline ) {
promises.push( sander.writeFile( dest + '.map', map.toString() ) );
}
return sander.Promise.all( promises );
}

@@ -201,0 +235,0 @@ };

5

lib/utils/getMapFromUrl.js

@@ -6,2 +6,4 @@ var path = require( 'path' ),

module.exports = function getMapFromUrl ( url, base, sync ) {
var json, map;
if ( /^data/.test( url ) ) {

@@ -15,3 +17,4 @@ match = /base64,(.+)$/.exec( url );

json = atob( match[1] );
return JSON.parse( json );
map = JSON.parse( json );
return sync ? map : sander.Promise.resolve( map );
}

@@ -18,0 +21,0 @@

@@ -1,6 +0,16 @@

var pattern = /\/\/#\s*sourceMappingURL=([^\s]+)/;
module.exports = function getSourceMappingUrl ( str ) {
var index, substring, url;
module.exports = function getSourceMappingUrl ( str ) {
var match = pattern.exec( str );
return match ? match[1] : null;
// assume we want the last occurence
index = str.lastIndexOf( 'sourceMappingURL' );
if ( index === -1 ) {
return null;
}
substring = str.substring( index + 17 );
match = /^\S+/.exec( substring );
url = match ? match[0] : null;
return url;
};
{
"name": "sorcery",
"description": "Resolve a chain of sourcemaps back to the original source",
"version": "0.2.0",
"version": "0.2.1",
"author": "Rich Harris",

@@ -21,3 +21,12 @@ "repository": "https://github.com/Rich-Harris/sorcery",

"sorcery": "bin/index.js"
}
},
"scripts": {
"test": "mocha",
"prepublish": "mocha"
},
"files": [
"lib/",
"bin/",
"README.md"
]
}

@@ -37,2 +37,14 @@ # sorcery.js

// write to a new file - this will create `output.js` and
// `output.js.map`, and will preserve relative paths. It
// returns a Promise
chain.write( 'output.js' );
// write to a new file, but append the flattened sourcemap as a data URI
chain.write( 'output.js', { inline: true });
// overwrite the existing file
chain.write();
chain.write({ inline: true });
// find the origin of line x, column y. Returns an object with

@@ -39,0 +51,0 @@ // `source`, `line`, `column` and (if applicable) `name` properties.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc