constantFolding

A function that takes a js code as argument and returns the same version after applying constant folding.

constantFolding(code: string): string
Parameters
code (string) A string with the input code.
Returns
string: Returns the equivalent code after applying constant folding.

replaceExpression

This function replaces the input node by its equivalent after applying constant folding

replaceExpression(n: Node)
Parameters
n (Node)

replaceLiteralAsIndex

This function replaces expressions of the type [1,2,3][2-1]

replaceLiteralAsIndex(node: Node)
Parameters
node (Node)

replaceLength

This function replaces expressions of the type [1,2,3].length

replaceLength(node: Node)
Parameters
node (Node)

replaceByLiteral

This function replaces this node contents with the reusult of running its operation with its left and right.

replaceByLiteral(node: Node)
Parameters
node (Node)