Functions
- constantFolding(code) ⇒
string
A function that transform an AST tree recognizing and evaluating constant expressions at compile time rather than computing them at runtime.
- replaceByLiteral(n)
Replace a BinaryExpression node with the result of the childs
- replaceByLength(n)
Replace a MemberExpression when is .length and folds to the size of the array
- replaceByJoin(n, divider)
Remplace a calleeExpression when is .join() and folds to a string of the elements
constantFolding(code) ⇒ string
A function that transform an AST tree recognizing and evaluating constant expressions at compile time rather than computing them at runtime.
Kind: global function
Returns: string
- Returns the transformed code
Param | Type | Description |
---|---|---|
code | string |
A string with the code to parse |
replaceByLiteral(n)
Replace a BinaryExpression node with the result of the childs
Kind: global function
Param | Type | Description |
---|---|---|
n | Node |
The node to replace to the result of the child node |
replaceByLength(n)
Replace a MemberExpression when is .length and folds to the size of the array
Kind: global function
Param | Type | Description |
---|---|---|
n | Node |
The node that calls .length |
replaceByJoin(n, divider)
Remplace a calleeExpression when is .join() and folds to a string of the elements
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
n | Node |
The node to join | |
divider | String |
, |
The divider that is between the elements of the array |