Comparing version 0.1.4 to 1.0.0
@@ -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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
13
1
56
7714
176