Purpose Statement: Create a price calculator command-line program in any language
Scope:
- Accept 2 command-line arguments
- Output the total price of the cart a. in cents b. followed by a newline character
- Handle products with any options, even ones not found in the sample files
- Time complexity to be O(n)
- Include thorough, automated tests
- Include any necessary instructions on how to install your program, run it, and run the tests
- Your code should clearly reflect and explain the problem domain
- Write code which you can easily extend
Domain Model: Domain Model for an Online Marketplace - Buyer only
Installation & Setup:
- Program runs on macOS/Linux only - not suitable for Windows due to filepath creation
- git clone this repo
- Install node.js -v 14.16.0
- Run npm install to install dependencies
- Save any files to be referenced in the source directory where index.js is located
Running the Program:
- Reference files (to pass to program) must be saved in the root directory where index.js is located
- cd to root directory
- Run either
npm startornode index.jsfollowed by TWO files(filename only). First is the file that you will use as the database. Second is the cart you wish to use at checkout File example/base-prices.jsonORbase-prices.jsonFull CLI examplenode index.js /base-prices.json /cart-4560.jsonORnode index.js base-prices.json cart-4560.json
Testing: Unit and Integration Tests have been written. The libraries used are mocha and chai with the 'expect' syntax A script has been created to enable automated testing of all tests.
- Run the test script to run all tests
For example:
npm test
Functionality: Redbubble has asked that the CLI program complete the following;
-
Accept 2 command-line arguments ARGV array accessed to save user input to appropriate constant variables
-
Output the total price of the cart a. in cents b. followed by a newline character console.log used to return constant variable from calculating function
-
Handle products with any options, even ones not found in the sample files
-
Time complexity to be O(n) .map and .filter methods both have a time complexity Big O Notation of O(n)
-
Include thorough, automated tests Mocha and chai testing packages have been required and utilised in the creation of unit, integration and end-to-end tests
-
Include any necessary instructions on how to install your program, run it, and run the tests Instructions included above under the headings; Installation & Setup, Running the Program, Testing
-
Your code should clearly reflect and explain the problem domain Code comments have been included where appropriate
-
Write code which you can easily extend The code has been written as components where possible to allow for ease of extension/modification
Node: scripts argv object keys javascript modules
fs; readFile and createReadStream: fs.createReadstream async/await readable stream fs.readfile fs.read streams fs.readFile
Buffer: Buffer Encoding
Big O Notation: Time Complexity diagrams
Path: path