anExpression lets you programmatically build JavaScript expressions, modify them, and then turn them into source code.
var anExpression = var javascriptToEzjs = var tree = anExpression
Once we have built a tree, we can query the data. Here we'll iterate through the key value pairs on that object expression, and expect to see the number 1:
var objectExpressionId = tree tree
We can also modify the tree:
tree
And then dump the modified code:
// tree.toJavaScript() returns:
Methods
// Adds an empty function literal at the next available positiontree // Add a string literal inside that function literalvar functionId = treevar stringLiteral = anExpressiontree
Expression generators
var hello = anExpression // "hello, world" anExpression // function add(a, b) {// "hello, world"// } var a = anExpression // 42 var b = anExpression // 1 anExpression // add(42, 1) anExpression // a anExpression // a = b anExpression // var c = b anExpression // {name: a} anExpression // [a, b] anExpressionanExpression // true anExpression // false anExpression // return a