@axetroy/vm
TypeScript icon, indicating that this package has built-in type declarations

0.3.8 • Public • Published

vm.js

Build Status Coverage Status License Prettier Node npm version Size

Run Javascript code in ECMAScript, without eval(), new Function(), setTimeout()...

It base on https://github.com/bramblex/jsjs

Try it out

Usage

import vm from "@axetroy/vm";

const sanbox = { console: console };

const context = vm.createContext(sanbox);

try {
  vm.runInContext(`console.log("Hello world");`, context);
} catch (err) {
  console.error(err);
}

Support

  • [x] ECMA5
  • [x] ES2015
    • [x] Let and const
    • [x] Block scoping
    • [x] ES modules
    • [x] Arrow functions
    • [x] Class
    • [x] Computed properties
    • [x] Destructuring
    • [x] For of
    • [x] Function/Class name
    • [x] Literals
    • [x] Object super
    • [x] Default and rest parameters
    • [x] Shorthand properties
    • [x] Spread
    • [x] Template literals
    • [x] Lifting template literal restriction
    • [ ] Unicode-regex
    • [x] Generator function
  • [ ] ES2016
    • [x] Exponentiation operator
  • [ ] ES2017
    • [x] Trailing commas in function parameter lists and calls
    • [ ] Async functions
    • [ ] Shared memory and atomics
  • [ ] ES2018
    • [ ] Asynchronous iteration
    • [ ] Promise.prototype.finally()
    • [ ] s (dotAll) flag for regular expressions
    • [ ] RegExp named capture groups
    • [ ] RegExp Unicode Property Escapes
  • [ ] Experimental

Test

I have written a lot of test case for this, look at here

Now it still in development, got a lot of work to do and more detail to resolve.

I will release the first stable version of write 500 test case.

If you want to join it. welcome to PR.

How to run a single test

npx tsc && npx ava ./build/test/ecma5/array/

How to run the whole test

npm run test

Related

bramblex/jsjs

jkeylu/evil-eval

License

The MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i @axetroy/vm

Weekly Downloads

1

Version

0.3.8

License

MIT

Unpacked Size

575 kB

Total Files

31

Last publish

Collaborators

  • axetroy