Socket
Socket
Sign inDemoInstall

load

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

29

index.js

@@ -21,7 +21,12 @@ 'use strict';

var name = path.basename(location)
, context = { load: require }
var context = { load: require }
, name = path.basename(location)
, code = read(location);
// Run it in a context so we can expose the globals
// Add the missing globals that are not present in vm module.
Object.keys(missing).forEach(function missingInVM(global) {
context[global] = missing[global];
});
// Run it in a context so we can expose the globals.
context = vm.createContext(context);

@@ -32,2 +37,7 @@ vm.runInContext(code, context, name);

if (context.load === require) delete context.load;
Object.keys(missing).forEach(function missingInVM(global) {
if (context[global] === missing[global]) {
delete context[global];
}
});

@@ -47,2 +57,15 @@ // If only one global was exported, we should simply expose it using the

/**
* The following properties are missing when loading plain ol files.
*
* @private
*/
var missing = {
console: console
, setTimeout: setTimeout
, clearTimeout: clearTimeout
, setInterval: setInterval
, clearInterval: clearInterval
};
/**
* Code reading and cleaning up.

@@ -49,0 +72,0 @@ *

2

package.json
{
"name": "load",
"version": "0.0.1",
"version": "0.0.2",
"description": "Load JavaScript files that do not use the bloat module patterns",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict';
function test() {
console.log('console.log(foo:bar)');
setTimeout(function () {
console.log('setTimeout()');
}, 100);
var x = setInterval(function () {
console.log('setInterval()');
clearTimeout(x);
}, 1000);
return 'foo:bar';
}
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