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-calculatebower install postfix-calculateUsage
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 testCredits
Algorithms for Parsing Arithmetic Expressions
License
MIT