node-retrieve-globals
Advanced tools
Comparing version 1.0.1 to 2.0.0
{ | ||
"name": "node-retrieve-globals", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Execute a string of JavaScript using Node.js and return the global variable values and functions.", | ||
"type": "module", | ||
"main": "moduleScript.cjs", | ||
"main": "retrieveGlobals.cjs", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "npx ava" |
import test from "ava"; | ||
import { ModuleScript } from "../moduleScript.cjs"; | ||
import { RetrieveGlobals } from "../retrieveGlobals.cjs"; | ||
test("var", t => { | ||
let vm = new ModuleScript("var a = 1;"); | ||
let vm = new RetrieveGlobals("var a = 1;"); | ||
t.deepEqual(vm.getGlobalContextSync(), { a: 1 }); | ||
@@ -19,3 +19,3 @@ }); | ||
let vm = new ModuleScript("var a = 1;"); | ||
let vm = new RetrieveGlobals("var a = 1;"); | ||
t.true(isPlainObject(vm.getGlobalContextSync())); | ||
@@ -26,3 +26,3 @@ }); | ||
test("var with data", t => { | ||
let vm = new ModuleScript("var a = b;"); | ||
let vm = new RetrieveGlobals("var a = b;"); | ||
t.deepEqual(vm.getGlobalContextSync({ b: 2 }), { a: 2 }); | ||
@@ -32,3 +32,3 @@ }); | ||
test("let with data", t => { | ||
let vm = new ModuleScript("let a = b;"); | ||
let vm = new RetrieveGlobals("let a = b;"); | ||
t.deepEqual(vm.getGlobalContextSync({ b: 2 }), { a: 2 }); | ||
@@ -38,3 +38,3 @@ }); | ||
test("const with data", t => { | ||
let vm = new ModuleScript("const a = b;"); | ||
let vm = new RetrieveGlobals("const a = b;"); | ||
t.deepEqual(vm.getGlobalContextSync({ b: 2 }), { a: 2 }); | ||
@@ -44,3 +44,3 @@ }); | ||
test("function", t => { | ||
let vm = new ModuleScript("function testFunction() {}"); | ||
let vm = new RetrieveGlobals("function testFunction() {}"); | ||
let ret = vm.getGlobalContextSync(); | ||
@@ -51,5 +51,7 @@ t.true(typeof ret.testFunction === "function"); | ||
test("async let", async t => { | ||
let vm = new ModuleScript(`let b = await Promise.resolve(1);`); | ||
let vm = new RetrieveGlobals(`let b = await Promise.resolve(1);`); | ||
let ret = await vm.getGlobalContext(); | ||
t.deepEqual(ret, { b: 1 }); | ||
}); | ||
}); | ||
// TODO code that parses fine but throws an error |
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
5789
127