kudzu
Fast evaluation on ESTree-compatible ASTs
Features
- Comprehensive tests
- Fully asynchronous API and internals
- Esprima and Cherow compatible
- ECMA 3 and IE8 compatible
- ESNext support
Install
npm install esprima-eval
Usage
var esEval = esprima = ; var ast = esprima scope = globals; scope; scope; scope;
Support
Runtime
- Strict mode
- Error handling
- Error skipping/resolution
- Protected global objects/prototypes
Globals
-
Array
-
Function
-
Object
-
Date
-
Number
-
RegExp
-
String
-
Proxy
-
Symbol
-
Math
Scope
- Scope chain
- Function scope (
var
) - Block scope (
let
)
Operations
- Binary (&, |, ^)
- Mathematical (+, -, /, *, %)
- Increment before (++i, --i)
- Increment after (i++, i--)
- Add assignment
- Subtract assignment
- Multiply assignment
- Divide assignment
- typeof
Conditionals
- And/or
- Strict/non-strict equality
- <, >, <=, >=
- instanceof
- If statements
Loops
- For loops
- While loops
-
break
-
continue
-
return
Functions
- Function declarations
- Anonymous closures
- Arrow functions
- Async functions
- Spread operator
- Object identity
Proxies
- Proxy constructor
- Has/get/set/delete property
- Get/set property descriptor
- Get/set prototype
- Apply
Promises
- Promise constructor
- Promise.then
- Promise.catch
Symbols
Errors
- Error constructor
- Stack traces
- Try/catch
# Prior Art
https://www.npmjs.com/package/esper.js https://www.npmjs.com/package/sandboxr https://github.com/NeilFraser/JS-Interpreter https://github.com/mozilla/narcissus/