https://github.com/alectrocute/rpn-code-test
https://github.com/alectrocute/rpn-code-test
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alectrocute/rpn-code-test
- Owner: alectrocute
- Created: 2022-01-27T03:01:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-28T19:48:13.000Z (over 4 years ago)
- Last Synced: 2026-04-16T03:37:06.128Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CLI RPN Calculator
==================
# Prerequisites
* Node >= 12.0
* Browser
# Run CLI
```js
cd ./rpn-code-test
node .
> 5 6 9 /
0.66666
```
# Testing
Run default test with cases listed at gist:
```js
yarn test
```
# Basic API
```js
const rpn = require('./rpn-code-test');
rpn.push(5);
const result = rpn.get();
console.log(result); // 5
rpn.clear();
rpn.push("5 6 9 /");
console.log(rpn.get()); // 0.66
```
# Commentary
* Built a basic CLI implementing an RPN calculator, including optional usage as headless API in Node or in the browser.
* Kept everything as simple and modular as I could.
* If I could do this all again, I'd think about validation more. I wouldn't be surprised if I missed quite a few input scenarios that break this calculator.