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.4 to 1.0.0

test/.tern-port

4

CHANGELOG.md

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

## 1.0.0
- Major: The API no longer automatically assumes an `module.exports` pattern. It
will always return an object with all introduced globals.
## 0.1.4

@@ -2,0 +6,0 @@ - Don't expose the `module.exports` and `exports` as predefined globals.

13

index.js

@@ -60,2 +60,3 @@ 'use strict';

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

@@ -67,2 +68,3 @@ if (context[global] === missing[global]) {

});
Object.keys(globals).forEach(function missingInVM(global) {

@@ -75,12 +77,3 @@ if (context[global] === globals[global]) {

// If only one global was exported, we should simply expose it using the
// `module.exports` patter. If there are more globals exported, expose them
// all.
globals = Object.keys(context);
if (globals.length === 1) return context[globals.pop()];
return globals.reduce(function reduce(exports, method) {
exports[method] = context[method];
return exports;
}, Object.create(null));
return context;
}

@@ -87,0 +80,0 @@

{
"name": "load",
"version": "0.1.4",
"version": "1.0.0",
"description": "Load plain JavaScript files that don't use module patterns directly in node.",

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

@@ -33,4 +33,5 @@ # load

// Only one global exported, automatically exposes the function by default.
var test = load('file.js');
// load returns all the introduced globals as an object, so specify the name of
// function you need in order to call it.
var test = load('file.js').test;

@@ -37,0 +38,0 @@ // file2.js contents:

@@ -7,7 +7,9 @@ 'use strict';

[{
it: 'exposes one single global? Assume module.exports.',
it: 'always a sumes an exports pattern with only 1 global',
does: function does() {
var test = load('./fixtures/file.js');
assert.ok(typeof test === 'function');
assert.ok(test() === 'foo:bar');
assert.ok(typeof test === 'object');
assert.ok(typeof test.test === 'function');
assert.ok(test.test() === 'foo:bar');
}

@@ -31,3 +33,3 @@ }, {

does: function () {
var stream = load('./fixtures/globals.js');
var stream = load('./fixtures/globals.js').x;
assert.ok(stream instanceof require('stream'));

@@ -34,0 +36,0 @@ }

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