1.0.0 • Published 2 years ago

infix-rpn-eval v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

infix-rpn-eval

master npm version GitHub forks GitHub issues GitHub license Maintainability Test Coverage

A JavaScript Implementation of Edsger Dijkstra's Shunting-yard algorithm. Works in Node.js and web browsers.

Installation

$ npm install infix-rpn-eval

Usage

Tokens must be space-separated! Unary - goes with its operand, e.g. -4

var infixRpnEval = require("infix-rpn-eval");

infixRpnEval.toPostfix('2 + 3 * 3');       // '2 3 3 * +'
infixRpnEval.toInfix('2 3 3 * +');         // '2 + 3 * 3'
infixRpnEval.evaluatePostfix('2 3 3 * +'); // 11
infixRpnEval.evaluateInfix('2 + 2 * 2');   // 6

infixRpnEval.evaluateInfix('a + b', {
  evaluateMathConstants: {
    // default
    pi: Math.PI,
    tau: Math.PI * 2,
    e: Math.E,
    // custom
    a: 100,
    b: 150
  }
}); // 250
1.0.0

2 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago