simple-calculator-saikat 1.0.0
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 +106 -0
- package/index.d.ts +4 -0
- package/index.js +27 -0
- package/package.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# simple-calculator-saikat
|
|
2
|
+
|
|
3
|
+
A simple and lightweight calculator utility for Node.js.
|
|
4
|
+
Provides basic math operations with clean and easy-to-use functions.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 📦 Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install simple-calculator-saikat
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🚀 Usage
|
|
17
|
+
|
|
18
|
+
### CommonJS (Node.js)
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const calc = require("simple-calculator-saikat");
|
|
22
|
+
|
|
23
|
+
console.log(calc.add(2, 3)); // 5
|
|
24
|
+
console.log(calc.subtract(5, 2)); // 3
|
|
25
|
+
console.log(calc.multiply(3, 4)); // 12
|
|
26
|
+
console.log(calc.divide(10, 2)); // 5
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### ES Modules (if supported)
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { add, subtract } from "simple-calculator-saikat";
|
|
35
|
+
|
|
36
|
+
console.log(add(2, 3)); // 5
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🧠 API
|
|
42
|
+
|
|
43
|
+
### ➕ add(a, b)
|
|
44
|
+
|
|
45
|
+
Returns the sum of two numbers.
|
|
46
|
+
|
|
47
|
+
### ➖ subtract(a, b)
|
|
48
|
+
|
|
49
|
+
Returns the difference between two numbers.
|
|
50
|
+
|
|
51
|
+
### ✖️ multiply(a, b)
|
|
52
|
+
|
|
53
|
+
Returns the product of two numbers.
|
|
54
|
+
|
|
55
|
+
### ➗ divide(a, b)
|
|
56
|
+
|
|
57
|
+
Returns the result of division.
|
|
58
|
+
|
|
59
|
+
⚠️ Throws an error if dividing by zero.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🛡️ Error Handling
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
calc.divide(10, 0);
|
|
67
|
+
// Error: Cannot divide by zero
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 💡 Example
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const { add, multiply } = require("simple-calculator-saikat");
|
|
76
|
+
|
|
77
|
+
const total = add(10, 5);
|
|
78
|
+
const result = multiply(total, 2);
|
|
79
|
+
|
|
80
|
+
console.log(result); // 30
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🧑💻 TypeScript Support
|
|
86
|
+
|
|
87
|
+
This package includes built-in TypeScript definitions.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { add } from "simple-calculator-saikat";
|
|
91
|
+
|
|
92
|
+
const result: number = add(2, 3);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 📄 License
|
|
98
|
+
|
|
99
|
+
MIT License © Saikat
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## ⭐ Contributing
|
|
104
|
+
|
|
105
|
+
Pull requests are welcome!
|
|
106
|
+
Feel free to open issues for bugs or feature requests.
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function add(a, b) {
|
|
4
|
+
return a + b;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function subtract(a, b) {
|
|
8
|
+
return a - b;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function multiply(a, b) {
|
|
12
|
+
return a * b;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function divide(a, b) {
|
|
16
|
+
if (b === 0) {
|
|
17
|
+
throw new Error("Cannot divide by zero");
|
|
18
|
+
}
|
|
19
|
+
return a / b;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
add,
|
|
24
|
+
subtract,
|
|
25
|
+
multiply,
|
|
26
|
+
divide,
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simple-calculator-saikat",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple and lightweight calculator utility for Node.js",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"index.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "node test.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"calculator",
|
|
16
|
+
"math",
|
|
17
|
+
"utility",
|
|
18
|
+
"nodejs"
|
|
19
|
+
],
|
|
20
|
+
"author": "Saikat",
|
|
21
|
+
"license": "MIT"
|
|
22
|
+
}
|