@alu0101337760/constant-folding

2.0.0 • Public • Published

npm version CI for constant-folding

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-folding

or 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 -h

Usage 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: alu0101337760@ull.edu.es
url: https://github.com/alu0101337760

Tests

To run the tests you can use:

npm test

/@alu0101337760/constant-folding/

    Package Sidebar

    Install

    npm i @alu0101337760/constant-folding

    Weekly Downloads

    0

    Version

    2.0.0

    License

    none

    Unpacked Size

    1.63 MB

    Total Files

    45

    Last publish

    Collaborators

    • alu0101337760