Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

insert-module-globals

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

insert-module-globals - npm Package Compare versions

Comparing version 6.1.0 to 6.2.0

44

index.js

@@ -8,2 +8,3 @@ var parseScope = require('lexical-scope');

var processPath = require.resolve('process/browser.js');
var combineSourceMap = require('combine-source-map');

@@ -93,3 +94,3 @@ var defaultVars = {

this.queue(closeOver(globals, source));
this.queue(closeOver(globals, source, file, opts));
this.queue(null);

@@ -101,3 +102,3 @@ }

function closeOver (globals, src) {
function closeOver (globals, src, file, opts) {
var keys = Object.keys(globals);

@@ -107,19 +108,32 @@ if (keys.length === 0) return src;

var wrappedSource;
if (keys.length <= 3) {
return '(function (' + keys.join(',') + '){\n'
wrappedSource = '(function (' + keys.join(',') + '){\n'
+ src + '\n}).call(this,' + values.join(',') + ')'
;
}
// necessary to make arguments[3..6] still work for workerify etc
// a,b,c,arguments[3..6],d,e,f...
var extra = [ '__argument0', '__argument1', '__argument2', '__argument3' ];
var names = keys.slice(0,3).concat(extra).concat(keys.slice(3));
values.splice(3, 0,
'arguments[3]','arguments[4]',
'arguments[5]','arguments[6]'
);
return '(function (' + names.join(',') + '){\n'
+ src + '\n}).call(this,' + values.join(',') + ')'
;
else {
// necessary to make arguments[3..6] still work for workerify etc
// a,b,c,arguments[3..6],d,e,f...
var extra = [ '__argument0', '__argument1', '__argument2', '__argument3' ];
var names = keys.slice(0,3).concat(extra).concat(keys.slice(3));
values.splice(3, 0,
'arguments[3]','arguments[4]',
'arguments[5]','arguments[6]'
);
wrappedSource = '(function (' + names.join(',') + '){\n'
+ src + '\n}).call(this,' + values.join(',') + ')';
}
// Generate source maps if wanted. Including the right offset for
// the wrapped source.
if (!opts.debug) {
return wrappedSource;
}
var sourceFile = path.relative(opts.basedir, file);
var sourceMap = combineSourceMap.create().addFile(
{ sourceFile: sourceFile, source: src},
{ line: 1 });
return combineSourceMap.removeComments(wrappedSource) + "\n"
+ sourceMap.comment();
}
{
"name": "insert-module-globals",
"version": "6.1.0",
"version": "6.2.0",
"description": "insert implicit module globals into a module-deps stream",

@@ -11,2 +11,3 @@ "main": "index.js",

"JSONStream": "~0.7.1",
"combine-source-map": "~0.3.0",
"concat-stream": "~1.4.1",

@@ -13,0 +14,0 @@ "lexical-scope": "~1.1.0",

Sorry, the diff of this file is not supported yet

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