Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-retrieve-globals

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-retrieve-globals - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

retrieveGlobals.cjs

4

package.json
{
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc