minimath-toolkit_pnn 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/index.js ADDED
@@ -0,0 +1,46 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const libName = 'MiniMathLib';
5
+ const srcDir = path.join(__dirname, 'src');
6
+
7
+ // Define the 20 files and their content
8
+ const files = {
9
+ 'basic/add.js': 'export const add = (a, b) => a + b;',
10
+ 'basic/subtract.js': 'export const subtract = (a, b) => a - b;',
11
+ 'basic/multiply.js': 'export const multiply = (a, b) => a * b;',
12
+ 'basic/divide.js': 'export const divide = (a, b) => a / b;',
13
+ 'basic/power.js': 'export const power = (a, b) => Math.pow(a, b);',
14
+
15
+ 'geometry/pi.js': 'export const PI = 3.14159;',
16
+ 'geometry/areaCircle.js': "import { PI } from './pi.js'; export const areaCircle = (r) => PI * r * r;",
17
+ 'geometry/areaSquare.js': 'export const areaSquare = (s) => s * s;',
18
+ 'geometry/perimRect.js': 'export const perimRect = (l, w) => 2 * (l + w);',
19
+ 'geometry/volCube.js': 'export const volCube = (s) => s * s * s;',
20
+ 'geometry/hypot.js': 'export const hypot = (a, b) => Math.sqrt(a*a + b*b);',
21
+ 'geometry/degToRad.js': "import { PI } from './pi.js'; export const degToRad = (d) => d * (PI / 180);",
22
+
23
+ 'utils/isEven.js': 'export const isEven = (n) => n % 2 === 0;',
24
+ 'utils/isOdd.js': 'export const isOdd = (n) => n % 2 !== 0;',
25
+ 'utils/round.js': 'export const round = (n) => Math.round(n);',
26
+ 'utils/randInt.js': 'export const randInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;',
27
+ 'utils/clamp.js': 'export const clamp = (v, min, max) => Math.min(Math.max(v, min), max);',
28
+ 'utils/min.js': 'export const min = (arr) => Math.min(...arr);',
29
+ 'utils/max.js': 'export const max = (arr) => Math.max(...arr);',
30
+
31
+ 'index.js': `
32
+ import * as basic from './basic/add.js';
33
+ // ... Simplified index for example
34
+ export const version = '1.0.0';
35
+ `
36
+ };
37
+
38
+ // Create folders and files
39
+ Object.entries(files).forEach(([filePath, content]) => {
40
+ const fullPath = path.join(srcDir, filePath);
41
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
42
+ fs.writeFileSync(fullPath, content);
43
+ console.log(`Created: ${filePath}`);
44
+ });
45
+
46
+ console.log('\nSuccess! 20 files created in the /src folder.');
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+
3
+ "name": "minimath-toolkit_pnn",
4
+ "version": "1.0.0",
5
+ "description": "A 20-file modular math library",
6
+ "main": "src/index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [],
11
+ "author": "PNN",
12
+ "license": "MIT",
13
+ "type": "module"
14
+ }
@@ -0,0 +1 @@
1
+ export const add = (a, b) => a + b;
@@ -0,0 +1 @@
1
+ export const divide = (a, b) => a / b;
@@ -0,0 +1 @@
1
+ export const multiply = (a, b) => a * b;
@@ -0,0 +1 @@
1
+ export const power = (a, b) => Math.pow(a, b);
@@ -0,0 +1 @@
1
+ export const subtract = (a, b) => a - b;
@@ -0,0 +1 @@
1
+ import { PI } from './pi.js'; export const areaCircle = (r) => PI * r * r;
@@ -0,0 +1 @@
1
+ export const areaSquare = (s) => s * s;
@@ -0,0 +1 @@
1
+ import { PI } from './pi.js'; export const degToRad = (d) => d * (PI / 180);
@@ -0,0 +1 @@
1
+ export const hypot = (a, b) => Math.sqrt(a*a + b*b);
@@ -0,0 +1 @@
1
+ export const perimRect = (l, w) => 2 * (l + w);
@@ -0,0 +1 @@
1
+ export const PI = 3.14159;
@@ -0,0 +1 @@
1
+ export const volCube = (s) => s * s * s;
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+
2
+ import * as basic from './basic/add.js';
3
+ // ... Simplified index for example
4
+ export const version = '1.0.0';
5
+
@@ -0,0 +1 @@
1
+ export const clamp = (v, min, max) => Math.min(Math.max(v, min), max);
@@ -0,0 +1 @@
1
+ export const isEven = (n) => n % 2 === 0;
@@ -0,0 +1 @@
1
+ export const isOdd = (n) => n % 2 !== 0;
@@ -0,0 +1 @@
1
+ export const max = (arr) => Math.max(...arr);
@@ -0,0 +1 @@
1
+ export const min = (arr) => Math.min(...arr);
@@ -0,0 +1 @@
1
+ export const randInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
@@ -0,0 +1 @@
1
+ export const round = (n) => Math.round(n);