JSPM

postfix-calculate

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q31840F
  • License

Calculate a postfix (Reverse Polish Notation) expression.

Package Exports

  • postfix-calculate

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 (postfix-calculate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postfix-calculate

Calculate a postfix (Reverse Polish Notation) expression.

Install

npm install postfix-calculate
bower install postfix-calculate

Usage

const postfixCalculate = require('postfix-calculate');

console.log(postfixCalculate('1 2 +')); // 3
console.log(postfixCalculate('3 4 5 + *')); // 27
console.log(postfixCalculate('3 4 * 2 5 + / 3 4 + *')); // 12
console.log(postfixCalculate('57.5 -34.1 - 6 3.2 / * 4.3 +')); // 176.05
console.log(postfixCalculate('a & 5')); // null (invalid expressions return null)

Test

npm test

Credits

Algorithms for Parsing Arithmetic Expressions

License

MIT