mini-math-kit 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 ADDED
@@ -0,0 +1,13 @@
1
+ # mini-math-kit
2
+
3
+ Simple math utilities for everyday use.
4
+
5
+ ## Install
6
+ npm install mini-math-kit
7
+
8
+ ## Usage
9
+ const math = require("mini-math-kit");
10
+
11
+ math.add(2, 3); // 5
12
+ math.isPrime(7); // true
13
+ math.average([1,2,3]); // 2
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ const math = {
2
+ add: (a, b) => a + b,
3
+ subtract: (a, b) => a - b,
4
+ multiply: (a, b) => a * b,
5
+ divide: (a, b) => b !== 0 ? a / b : null,
6
+
7
+ square: (n) => n * n,
8
+ cube: (n) => n * n * n,
9
+ power: (a, b) => Math.pow(a, b),
10
+ sqrt: (n) => Math.sqrt(n),
11
+
12
+ isEven: (n) => n % 2 === 0,
13
+ isOdd: (n) => n % 2 !== 0,
14
+
15
+ isPrime: (n) => {
16
+ if (n < 2) return false;
17
+ for (let i = 2; i <= Math.sqrt(n); i++) {
18
+ if (n % i === 0) return false;
19
+ }
20
+ return true;
21
+ },
22
+
23
+ sum: (arr) => arr.reduce((a, b) => a + b, 0),
24
+ average: (arr) => arr.reduce((a, b) => a + b, 0) / arr.length,
25
+ max: (arr) => Math.max(...arr),
26
+ min: (arr) => Math.min(...arr),
27
+
28
+ random: (min, max) =>
29
+ Math.floor(Math.random() * (max - min + 1)) + min
30
+ };
31
+
32
+ module.exports = math;
Binary file
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "mini-math-kit",
3
+ "version": "1.0.0",
4
+ "description": "Simple math utility functions for everyday use",
5
+ "main": "index.js",
6
+ "keywords": ["math", "utility", "simple", "numbers"],
7
+ "author": "Manibalan",
8
+ "license": "MIT"
9
+ }