b6ca7d6b75a8b082c5a860fb81dbe621a5140b61
Use the input value for the first line and shift stack lookups down for subsequent lines during edit mode. Also route Enter through execute() so editing state is handled consistently before re-rendering.
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 enginerpn-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:
pushpop
clearswap(index1, index2)remove(index)edit(index)isValidIndex(index)input(command)command(name, ...args)
inputValueis kept as a string to preserve future input formatsisEditingis exposed as a boolean state- All supported commands are described in one centralized dictionary
- Supported categories are limited to:
StackArithmeticTrigonometry
Basic usage
In a browser
Description
Languages
JavaScript
82.6%
Shell
17.4%