Vm.js
Javascript 解释器. Javascript Interpreter
Install / Use
/learn @axetroy/Vm.jsREADME
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
License
The MIT License
Related Skills
node-connect
335.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.7kCommit, push, and open a PR
