Socket
Socket
Sign inDemoInstall

@edge-runtime/vm

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edge-runtime/vm - npm Package Compare versions

Comparing version 2.2.0-beta.9 to 3.0.0-beta.10

5

dist/edge-vm.d.ts

@@ -21,7 +21,2 @@ import type * as EdgePrimitives from '@edge-runtime/primitives';

initialCode?: string;
/**
* Provides an initial map to the require cache.
* If none is given, it will be initialized to an empty map.
*/
requireCache?: VMOptions<T>['requireCache'];
}

@@ -28,0 +23,0 @@ export declare class EdgeVM<T extends EdgeContext = EdgeContext> extends VM<T> {

@@ -14,7 +14,2 @@ /// <reference types="node" />

extend?: (context: VMContext) => VMContext & T;
/**
* Provides an initial map to the require cache.
* If none is given, it will be initialized to an empty map.
*/
requireCache?: Map<string, Record<string | number, any>>;
}

@@ -27,4 +22,2 @@ /**

export declare class VM<T extends Record<string | number, any>> {
private readonly requireFn;
readonly requireCache: Map<string, Record<string | number, any>>;
readonly context: VMContext & T;

@@ -36,19 +29,2 @@ constructor(options?: VMOptions<T>);

evaluate<T = any>(code: string): T;
/**
* Allows to require a CommonJS module referenced in the provided file
* path within the VM context. It will return its exports.
*/
require<T extends Record<string | number, any> = any>(filepath: string): T;
/**
* Same as `require` but it will copy each of the exports in the context
* of the vm. Then exports can be used inside of the vm with an
* evaluated script.
*/
requireInContext<T extends Record<string | number, any> = any>(filepath: string): void;
/**
* Same as `requireInContext` but allows to pass the code instead of a
* reference to a file. It will create a temporary file and then load
* it in the VM Context.
*/
requireInlineInContext(code: string): void;
}

@@ -55,0 +31,0 @@ export interface VMContext {

36

dist/vm.js

@@ -5,4 +5,2 @@ "use strict";

const vm_1 = require("vm");
const require_1 = require("./require");
const temp_file_1 = require("./temp-file");
/**

@@ -15,3 +13,3 @@ * A raw VM with a context that can be extended on instantiation. Implements

constructor(options = {}) {
var _a, _b, _c, _d;
var _a, _b, _c;
const context = (0, vm_1.createContext)({}, {

@@ -24,5 +22,3 @@ name: 'Edge Runtime',

});
this.requireCache = (_b = options.requireCache) !== null && _b !== void 0 ? _b : new Map();
this.context = (_d = (_c = options.extend) === null || _c === void 0 ? void 0 : _c.call(options, context)) !== null && _d !== void 0 ? _d : context;
this.requireFn = (0, require_1.createRequire)(this.context, this.requireCache);
this.context = (_c = (_b = options.extend) === null || _b === void 0 ? void 0 : _b.call(options, context)) !== null && _c !== void 0 ? _c : context;
}

@@ -35,32 +31,4 @@ /**

}
/**
* Allows to require a CommonJS module referenced in the provided file
* path within the VM context. It will return its exports.
*/
require(filepath) {
return this.requireFn(filepath, filepath);
}
/**
* Same as `require` but it will copy each of the exports in the context
* of the vm. Then exports can be used inside of the vm with an
* evaluated script.
*/
requireInContext(filepath) {
const moduleLoaded = this.require(filepath);
for (const [key, value] of Object.entries(moduleLoaded)) {
this.context[key] = value;
}
}
/**
* Same as `requireInContext` but allows to pass the code instead of a
* reference to a file. It will create a temporary file and then load
* it in the VM Context.
*/
requireInlineInContext(code) {
const file = (0, temp_file_1.tempFile)(code);
this.requireInContext(file.path);
file.remove();
}
}
exports.VM = VM;
//# sourceMappingURL=vm.js.map

2

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://edge-runtime.vercel.app/packages/vm",
"version": "2.2.0-beta.9",
"version": "3.0.0-beta.10",
"main": "dist/index.js",

@@ -8,0 +8,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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