constantFolding

A function that takes js code in a string and applies constant folding to transform it

constantFolding(code: string): string
Parameters
code (string) A string containing the js code
Returns
string: Returns the transformed code as a string

replaceByLiteral

A function that takes an ast node and evaluates it's binary expresion in order to replace it with it's value

replaceByLiteral(n: any, code: any)
Parameters
n (any)
code (any) An ast node

replaceByArrayLength

A function that takes an ast node and evaluates it's member expresion in order to replace it with it's value In this case the member expression is array.length

replaceByArrayLength(n: any, code: any)
Parameters
n (any)
code (any) An ast node

replaceByArrayJoin

A function that takes an ast node and evaluates it's member expresion in order to replace it with it's value In this case the member expression is array.join().

replaceByArrayJoin(n: any, separator: any, code: any)
Parameters
n (any)
separator (any = ',')
code (any) An ast node

replaceByArraySquare

A function that takes an ast node and evaluates it's member expresion in order to replace it with it's value In this case the member expression is array[].

replaceByArraySquare(n: any, code: any)
Parameters
n (any)
code (any) An ast node

replaceByArrayPop

A function that takes an ast node and evaluates it's member expresion in order to replace it with it's value In this case the member expression is array.pop().

replaceByArrayPop(n: any, code: any)
Parameters
n (any)
code (any) An ast node

replaceByArrayConcat

A function that takes an ast node and evaluates it's member expresion in order to replace it with it's value In this case the member expression is array.concat().

replaceByArrayConcat(n: any, code: any)
Parameters
n (any)
code (any) An ast node