node-retrieve-globals
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "node-retrieve-globals", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Execute a string of JavaScript using Node.js and return the global variable values and functions.", | ||
@@ -21,3 +21,3 @@ "type": "module", | ||
"devDependencies": { | ||
"@zachleat/noop": "^1.0.2", | ||
"@zachleat/noop": "^1.0.3", | ||
"ava": "^5.2.0" | ||
@@ -24,0 +24,0 @@ }, |
@@ -69,1 +69,13 @@ # node-retrieve-globals | ||
``` | ||
### Advanced options | ||
```js | ||
// Defaults shown | ||
let options = { | ||
reuseGlobal: false, // re-use Node.js `global`, important if you want `console.log` to log to your console as expected. | ||
dynamicImport: false, // allows `import()` | ||
}; | ||
await vm.getGlobalContext({}, options); | ||
@@ -51,3 +51,20 @@ import test from "ava"; | ||
test("import", async t => { | ||
test("destructured assignment via object", async t => { | ||
let vm = new RetrieveGlobals(`const { a } = { a: 1 };`); | ||
let ret = await vm.getGlobalContext(); | ||
t.is(typeof ret.a, "number"); | ||
t.is(ret.a, 1); | ||
}); | ||
test("destructured assignment via Array", async t => { | ||
let vm = new RetrieveGlobals(`const [a, b] = [1, 2];`); | ||
let ret = await vm.getGlobalContext(); | ||
t.is(typeof ret.a, "number"); | ||
t.is(typeof ret.b, "number"); | ||
t.is(ret.a, 1); | ||
t.is(ret.b, 2); | ||
}); | ||
test("dynamic import", async t => { | ||
let vm = new RetrieveGlobals(`const { noop } = await import("@zachleat/noop");`); | ||
@@ -80,1 +97,2 @@ let ret = await vm.getGlobalContext(undefined, { | ||
}); | ||
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
10219
239
81