Socket
Socket
Sign inDemoInstall

infix-rpn-eval

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    infix-rpn-eval

Convert math expressions between postfix (RPN) and infix notations and evaluate them


Version published
Weekly downloads
19
decreased by-13.64%
Maintainers
1
Install size
13.4 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 12 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc