@pranavkok/mathterm 1.0.0 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/index.js +6 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# mathterm
|
|
2
|
+
|
|
3
|
+
A simple math calculator that runs right in your terminal. No browser, no app — just type a command and get your answer instantly.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @pranavkok/mathterm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Once installed, just run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
mathtermcli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You'll see a prompt like this:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Calculating ...
|
|
23
|
+
mathterm >
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
From here, type any math command and hit enter.
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
| Command | What it does | Example |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `add` | Adds all the numbers | `add 5 10 3` → 18 |
|
|
33
|
+
| `sub` | Subtracts from the first number | `sub 20 4 1` → 15 |
|
|
34
|
+
| `mul` | Multiplies all the numbers | `mul 2 3 4` → 24 |
|
|
35
|
+
| `div` | Divides the first number by the rest | `div 100 5 2` → 10 |
|
|
36
|
+
| `help` | Shows all available commands | `help` |
|
|
37
|
+
| `done` | Exits the program | `done` |
|
|
38
|
+
|
|
39
|
+
## Example Session
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Calculating ...
|
|
43
|
+
mathterm > add 10 20 30
|
|
44
|
+
Answer is 60
|
|
45
|
+
mathterm > sub 100 25 15
|
|
46
|
+
Answer is 60
|
|
47
|
+
mathterm > mul 3 4
|
|
48
|
+
Answer is 12
|
|
49
|
+
mathterm > div 200 4
|
|
50
|
+
Answer is 50
|
|
51
|
+
mathterm > done
|
|
52
|
+
Goodbye!
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Notes
|
|
56
|
+
|
|
57
|
+
- You can pass more than two numbers to any command — it'll chain the operation across all of them
|
|
58
|
+
- Type `help` anytime if you forget the commands
|
|
59
|
+
- Type `done` when you're finished — it'll say goodbye :)
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
ISC
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ console.log("Calculating ...");
|
|
|
5
5
|
|
|
6
6
|
let task = prompt("mathterm > ");
|
|
7
7
|
|
|
8
|
-
while (task !== "done") {
|
|
8
|
+
while (task !== null && task !== "done") {
|
|
9
9
|
task = task.trim();
|
|
10
10
|
const arr = task.split(' ');
|
|
11
11
|
if (arr[0] === "add") {
|
|
@@ -54,4 +54,9 @@ Commands:
|
|
|
54
54
|
task = prompt("mathterm > ");
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
if (task === null) {
|
|
58
|
+
console.log("\nGoodbye!");
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
console.log("Goodbye!");
|