@alu0101207957/constant-folding
v1.3.4
Published
Constant Folding javascript code
Downloads
13
Maintainers
Readme
Constant-Folding
Installation
Using npm
npm install @alu0101207957/constant-folding
Put it in the package.json
"dependencies": {
"@alu0101207957/constant-folding": "^1.3.3",
...
}
Usage as executable:
node bin/constant-folding-cli.js <input> -o <output>
It does constant folding to the code and return it in other file
Usage from code:
const constantFolding = require('constant-folding');
//call the function
The documentation of the function.
Examples
console.log(constantFolding(`12+7`));
//19
Author
alu0101207957 Andrés Zeus Hernández Impini
Tests
✔ Test 12+7 = 19;
✔ Test 12-7 = 5;
✔ Test 12+7-3-4; = 12;
✔ Test 12+7+a; = 19 + a;
✔ Test 12+7+"a"; = '19a';
✔ Test [1,2,3].length = 3;
✔ Test [1,2,3][2-1] = 2;
✔ Test [1,2,3].pop() = 3;
✔ Test [1,2,3].slice(0,1+1) = [
1,
2
];```