1.1.4 • Published 3 years ago

@alu0101325583/constant-folding v1.1.4

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

npm version CI for constant-folding

constant-folding

Installation

npm install @alu0101325583/constant-folding

Usage as executable:

cf input.js output.js

Usage from code:

const constantFolding = require('constant-folding');
//call the function

The documentation of the function.

Examples

let refactored = constantFolding(input);

Author

alu0101325583 Juan García Santos

Tests

npm test

API

Table of Contents

constantFolding

A function that given a certain code, builds its ast tree. Then, traverses through it, applaying constant folding on valid nodes

Parameters

  • code string A string that contains the input code generates the ast from the code, applys constant folding then generates code using the ast and escodegen.

Returns string Returns the simplified code

replaceByLiteral

A function that converts a given subtree known to be constant into a simplified literal node

Parameters

  • n Node the root node of the subtree evaluates the subtree and transforms it into a simplified literal node.
1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago