minimath-toolkit_pnn 1.0.0 → 1.0.1
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/Read.md +41 -0
- package/package.json +14 -3
package/Read.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 🧮 MiniMathLib
|
|
2
|
+
|
|
3
|
+
A lightweight, 20-file modular JavaScript toolkit for basic math, geometry, and utility functions.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start Examples
|
|
6
|
+
|
|
7
|
+
You can use MiniMathLib in two ways: by importing specific modules or using the main entry point.
|
|
8
|
+
|
|
9
|
+
### 1. Basic Arithmetic (Individual File Import)
|
|
10
|
+
Perfect for keeping your project size small by only loading what you need.
|
|
11
|
+
```javascript
|
|
12
|
+
import { add, power } from 'minimath-toolkit/src/basic/add.js';
|
|
13
|
+
|
|
14
|
+
console.log(add(10, 5)); // Result: 15
|
|
15
|
+
console.log(power(2, 3)); // Result: 8
|
|
16
|
+
|
|
17
|
+
import { areaCircle } from 'minimath-toolkit/src/geometry/areaCircle.js';
|
|
18
|
+
import { hypot } from 'minimath-toolkit/src/geometry/hypot.js';
|
|
19
|
+
|
|
20
|
+
// Calculate area of a pizza with 8-inch radius
|
|
21
|
+
const pizzaArea = areaCircle(8);
|
|
22
|
+
console.log(`The pizza is ${pizzaArea.toFixed(2)} square inches.`);
|
|
23
|
+
|
|
24
|
+
// Find the diagonal of a 3x4 rectangle
|
|
25
|
+
const diagonal = hypot(3, 4);
|
|
26
|
+
console.log(`The diagonal is ${diagonal}`); // Result: 5
|
|
27
|
+
|
|
28
|
+
import { isEven, randInt, clamp } from 'minimath-toolkit/src/utils/index.js';
|
|
29
|
+
|
|
30
|
+
console.log(isEven(7)); // Result: false
|
|
31
|
+
console.log(randInt(1, 10)); // Result: (Random number 1-10)
|
|
32
|
+
|
|
33
|
+
// Keep a health bar between 0 and 100
|
|
34
|
+
let health = 150;
|
|
35
|
+
health = clamp(health, 0, 100);
|
|
36
|
+
console.log(health); // Result: 100
|
|
37
|
+
|
|
38
|
+
Category,File Count,Key Functions
|
|
39
|
+
Basic,5 Files,"add, subtract, multiply, divide, power"
|
|
40
|
+
Geometry,7 Files,"areaCircle, volCube, hypot, degToRad"
|
|
41
|
+
Utils,8 Files,"isEven, randInt, clamp, min/max"
|
package/package.json
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "minimath-toolkit_pnn",
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
"version": "1.0.1",
|
|
6
|
+
|
|
5
7
|
"description": "A 20-file modular math library",
|
|
8
|
+
|
|
6
9
|
"main": "src/index.js",
|
|
10
|
+
|
|
7
11
|
"scripts": {
|
|
8
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
+
|
|
9
16
|
},
|
|
17
|
+
|
|
10
18
|
"keywords": [],
|
|
19
|
+
|
|
11
20
|
"author": "PNN",
|
|
21
|
+
|
|
12
22
|
"license": "MIT",
|
|
13
|
-
|
|
23
|
+
|
|
24
|
+
"type": "module"
|
|
14
25
|
}
|