smelukov / estel Goto Github PK
View Code? Open in Web Editor NEWESTree AST interpreter with dynamic analyzing
License: MIT License
ESTree AST interpreter with dynamic analyzing
License: MIT License
a = [1, 2, 3]; // create array property for token
obj = { [a]: a}; // obj = { '1,2,3,4': [1,2,3,4] }
var a = 1;
var b = `some {$a} template`
Hi, thanks for this really cool package! I was playing around with it, and I was wondering if it is possible to add variables to the top level scope somehow. Something like:
const a = 1;
const b = 2;
const ast = espree.parse('const result = a + b')
const scope = new estel.Scope();
// add a and b to scope somehow
estel.processNames(ast, scope);
estel.processValues(ast);
const resultRef = scope.getReference("result");
console.log(resultRef.value); // should be 3
Is it possible to do something similar?
var [a, b] = [1, 2]; // a = 1, b = 2
var { a, b } = { a: 1, b: 2 }; // a = 1, b = 2
var { a: { b: a, c: b } } = { a: { b: 1,c: 2 } }; // a = 1, b = 2
a = 1;
b = 2;
c = a + b; // 3
a++;
++a;
a--;
--a;
function Fn(a, b) {
return a + b;
}
a = Fn(1, 2); // 3
arguments
variableReturnStatement
CallExpression
)Create names for:
import a from 'some';
import {a, b, c as d} from 'some';
import * as d from 'some';
Blocked by jquery/esprima#1826
function A(){
function B(){
console.log(arguments.callee) // function B() { ... }
console.log(B.caller) // function A() { ... }
}
B();
}
A();
a = b.c.d;
a.b.c = d;
a[b].c = d;
a = b[0];
a[0] = b;
var a = 1;
if(a) { ... }
var a = b || 0;
var a = b && b.c;
a.push(4); // intercept array modifications and modify `token.array`
b = a.slice(1); // intercept array slicing and return new token with new `array` field
push
, pop
, splice
, sort
, shift
, unshift
, length = ...
)a = b ? c : d;
var a = +1;
var a = +'1';
c = 2;
d = 'd';
obj = { a: 1, b: c, [d]: { e: 2 } }; // { a: 1, b: 2, d: { e: 2 } }
a += 1;
a -= 1;
// etc...
a = b = c;
a = b.c.d = e;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.