JSPM

@alu0101353647/constant-folding

1.10.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q37664F
  • License Unlicense

Constant Folding javascript code

Package Exports

  • @alu0101353647/constant-folding
  • @alu0101353647/constant-folding/src/constant-folding.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@alu0101353647/constant-folding) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Review Assignment Due Date Open in Codespaces

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.