node-retrieve-globals
Advanced tools
Comparing version 2.0.7 to 2.0.8
{ | ||
"name": "node-retrieve-globals", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Execute a string of JavaScript using Node.js and return the global variable values and functions.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -18,3 +18,3 @@ import test from "ava"; | ||
}; | ||
let vm = new RetrieveGlobals("var a = 1;"); | ||
@@ -33,3 +33,3 @@ t.true(isPlainObject(vm.getGlobalContextSync())); | ||
}; | ||
let vm = new RetrieveGlobals("var a = { b: 1, c: { d: {} } };"); | ||
@@ -41,3 +41,23 @@ let obj = vm.getGlobalContextSync(); | ||
test("isPlainObject deep circular", t => { | ||
// from eleventy-utils | ||
function isPlainObject(value) { | ||
if (value === null || typeof value !== "object") { | ||
return false; | ||
} | ||
let proto = Object.getPrototypeOf(value); | ||
return !proto || proto === Object.prototype; | ||
}; | ||
let vm = new RetrieveGlobals(` | ||
var a = { a: 1 }; | ||
var b = { b: a }; | ||
a.b = b; | ||
`); | ||
let obj = vm.getGlobalContextSync(); | ||
t.true(isPlainObject(obj.a.b)); | ||
t.true(isPlainObject(obj.b.b)); | ||
}); | ||
test("var with data", t => { | ||
@@ -44,0 +64,0 @@ let vm = new RetrieveGlobals("var a = b;"); |
Sorry, the diff of this file is not supported yet
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
13267
284