@alu0101353647/constant-folding
v1.10.1
Published
Constant Folding javascript code
Downloads
14
Maintainers
Readme
constant-folding
This is a small library made to fold the constants and similar expressions that
can be folded before runtime. The bulk of the functionalities are bunched up within one function, constantFolding
, which receives as parameter the code whose constants to fold.
This code goes the extra length with some of the functionalities, despite the author not having time to make the extras in the rubric.
Published in npm!
Installation
npm install @alu0101353647/constant-folding
Usage as executable:
Within input.txt
we have lines of code whose constants to fold. The code will dump the better code at output.txt
.
cf input.txt output.txt
Usage from code:
const constantFolding = require('constant-folding');
console.log(constantFolding(`a=[2*2].concat(3, [5,6], [[4]]);`));
The documentation of the function.
Examples
See the tests attached in the repository
Author
alu0101353647, the one and only. Also known as Guillermo Zafra.
Tests
Every test already within the rubric has been added. Additionally, tests with other binary expressions have been added, as well as a complex test.