Files
mtm-rpn-js/README.md
T

1.2 KiB

RPN Virtual Calculator

A browser-friendly RPN calculator built around a small, generic JavaScript API.

Goal

This project defines a reusable RPN calculator engine with:

  • a simple stack-based public API
  • configurable numeric and UI behavior
  • centralized command metadata
  • a browser demo that uses the same public API as any consumer code

Package contents

  • rpn-calculator.js: calculator engine
  • rpn-example.html: example browser interface

Main features

  • Single JavaScript class
  • Configurable stack size (maxSize, default: 2048)
  • Configurable numeric base (base, default: 10)
  • Configurable angle mode (angleMode, default: deg)
  • Optional command filtering through enabledCommands
  • Generic public API centered on:
    • push
    • pop
  • clear
    • swap(index1, index2)
    • remove(index)
    • edit(index)
    • isValidIndex(index)
    • input(command)
    • command(name, ...args)
  • inputValue is kept as a string to preserve future input formats
  • isEditing is exposed as a boolean state
  • All supported commands are described in one centralized dictionary
  • Supported categories are limited to:
    • Stack
    • Arithmetic
    • Trigonometry

Basic usage

In a browser