Giter Site home page Giter Site logo

estel's People

Contributors

smelukov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

smallwolf1991

estel's Issues

Support ArrayExpression

a = [1, 2, 3]; // create array property for token
obj = { [a]: a}; // obj = { '1,2,3,4': [1,2,3,4] }

Is it possible to add variables to the top level scope?

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?

Support destructuring assignment

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

Checklist

Names processor

  • create names from array destructuring
  • create names from object destructuring

Values processor

  • handle tokens of array destructuring
  • handle tokens of object destructuring

Support CallExpression

function Fn(a, b) {
  return a + b;
}

a = Fn(1, 2); // 3

Checklist

  • pass arguments to parameters
  • pass arguments to arguments variable
  • support ReturnStatement
  • support runner (function, that calls by CallExpression)

Support arguments.callee and caller

function A(){
    function B(){
        console.log(arguments.callee) // function B() { ... }
        console.log(B.caller) // function A() { ... }
    }
    B();
}
A();

Support MemberExpression assignments

a = b.c.d;
a.b.c = d;
a[b].c = d;

a = b[0];
a[0] = b;

Checklist

  • static member expression in right side
  • static member expression in left side
  • dynamic member expression in right side
  • dynamic member expression in left side

Intercept array methods

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

Checklist

  • intercept array modifications (push, pop, splice, sort, shift, unshift, length = ...)
  • intercept array slicing

Support ObjectExpression

c = 2;
d = 'd';
obj = { a: 1, b: c, [d]: { e: 2 } }; // { a: 1, b: 2, d: { e: 2 } }

Checklist

  • literal as value
  • identifier as value
  • object expression as value
  • literal as key
  • identifier as key
  • computed key

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.