Table of Contents
This product is a command-line interface for an RPN Calculator. Reverse Polish Calculators are different from standard calculators, in which operators follow their operands. For example, "3 2 +" equates to "5" in an RPN calculator.
This product enables arithmetic calculations with two operands and four basic operations (addition, subtraction, multiplication, and division).
The backbone of the product in terms of data structure is the "stack", where its LIFO (Last In Frist Out) concept perfectly aligns with the RPN logic.
In terms of data validation, "Regex" (Regular expression) is used to simply validate the user input against the currently available operators.
The Node.js "stream" interface (more specifically "readline" module) is used to enable future scalability of the product. The current "readable" and "writable" streams can conveniently be changed to work with the local file system through the "fs" native module. Moreover, the "duplex" stream can be used to enable the "TCP socket" interface.
There are a few items that can be added to further improve the product:
- Add additional unit tests to increase the test code coverage as well as to include the asynchronous callbacks.
- Implement integration tests to ensure the full functionality of the child processes in the command line.
- The current product only accepts two-operand calculations. Expand the code to include uni-operand calculations.
To start the application, simply run "node index.js" command from the directory. To run the tests, run "npm run test".