0.2.2 • Published 12 months ago
@whi/isolated-execution v0.2.2
Isolated Execution
A (node) module for running code with a controlled global context.
Overview
This module is intended to provide more deterministic controls to the native
vm
library.
Features
- Prevent access to
process
inside VM - Support multiple input types for code
Install
npm i @whi/isolated-execution
Basic Usage
import { VM, Script } from '@whi/isolated-execution';
let vm = new VM({
console,
});
let code = new Script(() => {
console.log("Hello world");
});
vm.run( code );
code.run( context );
IO Support
When the run
input is a function, input/output controls are supported.
let vm = new VM({});
let greeting = vm.run( ( first_name, last_name ) => {
return `Hello, ${first_name} ${last_name}`;
}, "Robin", "Williams" );
// Hello, Robin Williams
API Reference
See docs/API.md
Contributing
See CONTRIBUTING.md