@alu0101337760/constant-folding
v2.0.0
Published
Constant Folding javascript code
Maintainers
Readme
constant-folding
This package offers utility to apply constant folding optimization to Javascript code.
Installation
To install this package you can type:
npm i @alu0101337760/constant-foldingor add this entry to your package.json file:
{
"@alu0101337760/constant-folding": "^1.1.1"
}Usage as executable:
To run the executable you can type:
npx cf <input_file> -o <output_file>This command reads the contents of the input file and writes in the output file the result of applying the constant folding.
You can see the information in detail with the option -h:
npx cf -hUsage from code:
The constantFolding() function, takes a String containing Javascript source code as a parameter and returns the
const constantFolding = require('constant-folding');
let foldedCode = constantFolding("string");The documentation of the function.
Examples
From code:
const example4 = `30+2-4`;
console.log(constantFolding(example));
// output: 28;Author
name: Enrique Viña Alonso
email: [email protected]
url: https://github.com/alu0101337760
Tests
To run the tests you can use:
npm test