@pablo-pg/constant-folding
v1.4.0
Published
Constant Folding javascript code
Downloads
13
Maintainers
Readme
constant-folding
Installation
Write on terminal:
$ npm i @pablo-pg/constant-folding
The output will be similar to this:
Usage as executable:
After install the package, can be executed with cf
:
$ cf input.js
There is an example of using it inside a script in package.json:
There is also an help message:
Usage from code:
Just write the require and then use the function constantFolding(strCode)
.
const constantFolding = require('@pablo-pg/constant-folding');
//call the function
The documentation of the function.
Examples
The original code:
let x = 2 + 3 - 5;
let len = [1,2,3].length;
let str = [3,2,1].join('-');
Will produce the next code:
let x = 0;
let len = 3;
let str = '3-2-1';
There is the comprobation:
Author
Name: Pablo Pérez González
email: [email protected]
Tests
Test from the production:
Coverage: