0.2.2 • Published 12 months ago

@whi/isolated-execution v0.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

npm.io

Isolated Execution

A (node) module for running code with a controlled global context.

npm.io npm.io npm.io

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

0.2.1

12 months ago

0.2.0

12 months ago

0.2.2

12 months ago

0.1.1

1 year ago

0.1.0

1 year ago