@yeanzhi/vm
v0.0.3
Published
Javascript Interpreter, run Javascript code in ECMAScript
Downloads
5
Readme
vm.js
Run Javascript code in ECMAScript, without eval(), new Function(), setTimeout()...
It base on https://github.com/bramblex/jsjs
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
- [x] Object rest spread
- [x] Class property
- [x] Do expressions
- [ ] Optional catch binding
- [ ] Decorators
- [x] Global
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
Contributors
| Axetroy💻 🔌 ⚠️ 🐛 🎨 | | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
License
The MIT License