1.2.1 • Published 3 years ago

@alu0101315058/constant-folding v1.2.1

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

npm version CI for constant-folding

constant-folding

Installation

You can add @alu0101315058/constant-folding to your proyect's dependencies or use:

npm i @alu0101315058/constant-folding

Usage as executable:

To use this module as an executable, you can type:

npx cf <input_file> [-o <output file>]

Usage from code:

const constantFolding = require('constant-folding');
...
let folded = constantFolding(codeInString);

The documentation of the function.

Examples

constantFolding("a = 5*2+1") //outputs "a = 11;"
constantFolding("[1, 2, 3].length;") //outputs "3;"
constantFolding("[1, 2, 3][2-1];") //outputs "2;"
constantFolding("[1, 2, 3].shift();") //outputs "[\n    2,\n    3];"
constantFolding("[a, b, c].pop();") //outputs "c;"
constantFolding("[a, b, c].reverse();") //outputs "[\n    c,\n    b,\n    a];"

Author

Name: Dario Cerviño Luridiana E-mail: alu0101315058@ull.edu.es

Tests

There are some tests already made for this module. They can be executed from the root of the module using:

npm test