Global

Methods

constantFolding(code) → {string}

This function get passed some code and then it forms an AST tree with it. After it traverses the tree doing constant folding in different nodes in which it is possible to perform it
Parameters:
Name Type Description
code string The javascript input code
Source:
Returns:
Generated js code from the resultant tree
Type
string

getValues(elem) → {*}

This function gets passed by a Node and depending on its type will perform different operations.
Parameters:
Name Type Description
elem Obect Single subNode
Source:
Returns:
Return single element from passed Node
Type
*

transLiteralNode(n)

This Function takes a Node of type BinaryExpression and perform constant Folding on it
Parameters:
Name Type Description
n Object Node with a type of BinaryExpression
Source:

transNode(n, args)

This function gets passed two arguments and perform a transformation in the node depending different parameters. Then it creates a new node object that will substitute the passed one.
Parameters:
Name Type Description
n Object Node object in which constant folding will be applied
args * Possible arguments this node has ex: [a].concat([b]), [b] are the args here
Source: