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.1.0 to 0.1.1

.tern-port

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.1.1
- Make it possible to add globals to the loaded script.
- Added missing `__dirname` and `__filename`.
## 0.1.0

@@ -2,0 +6,0 @@ - It exposes the compiler.

@@ -21,3 +21,6 @@ 'use strict';

return compiler(read(location), path.basename(location));
return compiler(read(location), path.basename(location), {
__filename: path.basename(location),
__dirname: path.dirname(location)
});
}

@@ -30,6 +33,10 @@

* @param {String} name The name of the file.
* @param {Object} globals Additional globals
* @returns {Mixed} Things.
* @api public
*/
function compiler(code, name) {
function compiler(code, name, globals) {
name = name || 'load.js';
globals = globals || {};
var context = { load: require };

@@ -42,2 +49,7 @@

// Add extra globals.
Object.keys(globals).forEach(function missingInVM(global) {
context[global] = globals[global];
});
// Run it in a context so we can expose the globals.

@@ -54,2 +66,7 @@ context = vm.createContext(context);

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

@@ -59,3 +76,3 @@ // If only one global was exported, we should simply expose it using the

// all.
var globals = Object.keys(context);
globals = Object.keys(context);

@@ -62,0 +79,0 @@ if (globals.length === 1) return context[globals.pop()];

2

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

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

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