@alu0101325583/constant-folding
v1.1.4
Published
Constant Folding javascript code
Maintainers
Readme
constant-folding
Installation
npm install @alu0101325583/constant-foldingUsage as executable:
cf input.js output.jsUsage from code:
const constantFolding = require('constant-folding');
//call the functionThe documentation of the function.
Examples
let refactored = constantFolding(input);Author
alu0101325583 Juan García Santos
Tests
npm testAPI
Table of Contents
constantFolding
A function that given a certain code, builds its ast tree. Then, traverses through it, applaying constant folding on valid nodes
Parameters
codestring A string that contains the input code generates the ast from the code, applys constant folding then generates code using the ast and escodegen.
Returns string Returns the simplified code
replaceByLiteral
A function that converts a given subtree known to be constant into a simplified literal node
Parameters
nNode the root node of the subtree evaluates the subtree and transforms it into a simplified literal node.
