RPN
LIB-
Reverse Polish Notation calculator written in TypeScript
rpn-ts is a lightweight Reverse Polish Notation calculator implemented in TypeScript.
It supports stack-based evaluation of basic mathematical expressions using common operators like +
, -
, *
, and /
. Useful for embedded calculations, REPLs, or scripting environments where postfix logic is preferred.
Features:
- Postfix notation (RPN) expression parser
- Stack-based evaluation
- Basic arithmetic operator support
- Modular ESM/CJS builds
- Zero dependencies
Example:
evaluateRPN("3 4 + 2 *"); // returns 14
evaluateRPN("5 1 2 + 4 * + 3 -"); // returns 14