File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,8 @@ link when you’re done.
16
16
8 . Split it up into a frontend and a backend (use the MERN stack)
17
17
9 . Using typescript will be a bonus.
18
18
10 . Please avoid using the eval-cmd of the JS math library
19
- 11 . The more effort you put into it (e.g. design wise, documentation wise) the better the rating will be.
19
+ 11 . The more effort you put into it (e.g. design wise, documentation wise) the better the rating will be.
20
+
21
+ ## How to start
22
+ 1 . follow the instructions in [ backend/README.md] ( backend/README.md#run-at-local ) to start backend server
23
+ 2 . follow the instructions in [ frontend/README.md] ( frontend/README.md#run-at-local ) to start frontend
Original file line number Diff line number Diff line change @@ -16,7 +16,27 @@ npm run start
16
16
npm run test
17
17
```
18
18
19
- ## Limitations on calculation
19
+ ## Features
20
+ - [x] It supports 2 types of operations requested via websocket
21
+ - ` operation ` : evaluate an expression and return the result.
22
+ - ` history ` : get the latest 10 commands and results.
23
+ - [x] [ Express] ( https://expressjs.com/ ) is used for the server and router.
24
+ - [x] [ Socket.io] ( https://socket.io/ ) is used for WebSocket communication.
25
+ - [x] [ MongoDB] ( https://www.mongodb.com/ ) is used for storing chat history.
26
+ - [ Array $slice] ( https://www.mongodb.com/docs/manual/reference/operator/update/slice/ ) is used to keep only the latest history.
27
+ - [x] [ Jest] ( https://jestjs.io/ ) is used for unit testing.
28
+ - [x] [ Github Workflows] ( ../.github/workflows/ci.yaml ) is used for continuous integration.
29
+
30
+ ## Math Calculation
31
+ ### Evalutaion Algorithm
32
+ 1 . Parse the expression string by splitting by ` + ` and ` - ` , resulting a list of sub-expressions (` ExpressionMD ` ).
33
+ 2 . For each sub-expression, turn it into a ` Fraction ` .
34
+ 3 . Sum all fractions by ` Fraction.add(Fraction) ` .
35
+ - It uses ** lowest common multiple** to add fractions.
36
+ - [ Decimal.js] ( https://mikemcl.github.io/decimal.js/ ) is used for the basic arithmetic operations.
37
+ 4 . Evaluate the result by ` Fraction.evaluate() ` .
38
+
39
+ ### Limitations
20
40
- All whitespace is ignored, therefore ` 1 + 2 3 ` will consider as ` 1 + 23 `
21
41
- ` negative sign ` is only allowed at the beginning of an expression but not after multiplication or division
22
42
- e.g. ` -5*3 + 1 ` will return ` -14 `
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ npm install
6
6
cp .env.example .env # modify as needed
7
7
```
8
8
9
- ## Start Locally
9
+ ## Run at Local
10
10
```
11
11
npm run build
12
12
npm run preview
You can’t perform that action at this time.
0 commit comments