UNPKG

@alu0101350158/constant-folding

Version:
141 lines (110 loc) 3.93 kB
## Functions <dl> <dt><a href="#constantFolding">constantFolding(code)</a><code>string</code></dt> <dd><p>A function that takes js code in a string and applies constant folding to transform it</p> </dd> <dt><a href="#replaceByLiteral">replaceByLiteral(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s binary expresion in order to replace it with it&#39;s value</p> </dd> <dt><a href="#replaceByArrayLength">replaceByArrayLength(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s member expresion in order to replace it with it&#39;s value In this case the member expression is array.length</p> </dd> <dt><a href="#replaceByArrayJoin">replaceByArrayJoin(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s member expresion in order to replace it with it&#39;s value In this case the member expression is array.join().</p> </dd> <dt><a href="#replaceByArraySquare">replaceByArraySquare(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s member expresion in order to replace it with it&#39;s value In this case the member expression is array[].</p> </dd> <dt><a href="#replaceByArrayPop">replaceByArrayPop(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s member expresion in order to replace it with it&#39;s value In this case the member expression is array.pop().</p> </dd> <dt><a href="#replaceByArrayConcat">replaceByArrayConcat(code)</a></dt> <dd><p>A function that takes an ast node and evaluates it&#39;s member expresion in order to replace it with it&#39;s value In this case the member expression is array.concat().</p> </dd> </dl> <a name="constantFolding"></a> ## constantFolding(code) ⇒ <code>string</code> A function that takes js code in a string and applies constant folding to transform it **Kind**: global function **Returns**: <code>string</code> - Returns the transformed code as a string | Param | Type | Description | | --- | --- | --- | | code | <code>string</code> | A string containing the js code | <a name="replaceByLiteral"></a> ## replaceByLiteral(code) A function that takes an ast node and evaluates it's binary expresion in order to replace it with it's value **Kind**: global function | Param | Description | | --- | --- | | code | An ast node | <a name="replaceByArrayLength"></a> ## replaceByArrayLength(code) 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 **Kind**: global function | Param | Description | | --- | --- | | code | An ast node | <a name="replaceByArrayJoin"></a> ## replaceByArrayJoin(code) 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(). **Kind**: global function | Param | Description | | --- | --- | | code | An ast node | <a name="replaceByArraySquare"></a> ## replaceByArraySquare(code) 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[]. **Kind**: global function | Param | Description | | --- | --- | | code | An ast node | <a name="replaceByArrayPop"></a> ## replaceByArrayPop(code) 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(). **Kind**: global function | Param | Description | | --- | --- | | code | An ast node | <a name="replaceByArrayConcat"></a> ## replaceByArrayConcat(code) 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(). **Kind**: global function | Param | Description | | --- | --- | | code | An ast node |