Comparing version 0.1.7 to 0.1.8
19
eval.js
@@ -8,5 +8,3 @@ var vm = require('vm') | ||
if (!a || !b) return a | ||
// Include all non-enumerable variables, including console (v10+), | ||
// process (v12+), URL, etc. | ||
var keys = Object.getOwnPropertyNames(b) | ||
var keys = Object.keys(b) | ||
for (var k, i = 0, n = keys.length; i < n; i++) { | ||
@@ -19,2 +17,5 @@ k = keys[i] | ||
var vmGlobals = new vm.Script('Object.getOwnPropertyNames(globalThis)') | ||
.runInNewContext() | ||
// Return the exports/module.exports variable set in the content | ||
@@ -42,3 +43,15 @@ // content (String|VmScript): required | ||
if (includeGlobals) { | ||
// Merge enumerable variables on `global` | ||
merge(sandbox, global) | ||
// Merge all non-enumerable variables on `global`, including console (v10+), | ||
// process (v12+), URL, etc. We first filter out anything that's already in | ||
// the VM scope (i.e. those in the ES standard) so we don't have two copies | ||
Object.getOwnPropertyNames(global).forEach((name) => { | ||
if (!vmGlobals.includes(name)) { | ||
sandbox[name] = global[name] | ||
} | ||
}) | ||
// `console` exists in VM scope, but we want to pipe the output to the | ||
// process' | ||
sandbox.console = console | ||
sandbox.require = requireLike(_filename) | ||
@@ -45,0 +58,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
, "keywords": ["require","eval","vm","module"] | ||
, "version": "0.1.7" | ||
, "version": "0.1.8" | ||
, "homepage": "http://github.com/pierrec/node-eval" | ||
@@ -9,0 +9,0 @@ , "repository": { |
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
8304
149