@jangaba/qube 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.
Files changed (3) hide show
  1. package/index.d.ts +14 -14
  2. package/index.js +28 -28
  3. package/package.json +4 -1
package/index.d.ts CHANGED
@@ -1,25 +1,25 @@
1
1
  export interface CubeResult {
2
- /** Dlzka hrany */
2
+ /** Edge length */
3
3
  edge: number;
4
- /** Uhlopriecka steny (podstavy): a√2 */
4
+ /** Face diagonal: a√2 */
5
5
  faceDiagonal: number;
6
- /** Telesova uhlopriecka: a√3 */
6
+ /** Space diagonal: a√3 */
7
7
  spaceDiagonal: number;
8
- /** Povrch kocky: 6a² */
8
+ /** Surface area: 6a² */
9
9
  surfaceArea: number;
10
- /** Objem kocky: a³ */
10
+ /** Volume: a³ */
11
11
  volume: number;
12
- /** Obsah jednej steny: a² */
12
+ /** Face area: a² */
13
13
  faceArea: number;
14
- /** Obvod jednej steny: 4a */
14
+ /** Face perimeter: 4a */
15
15
  perimeter: number;
16
- /** Sucet dlzok vsetkych hran: 12a */
16
+ /** Total edge length: 12a */
17
17
  totalEdgeLength: number;
18
- /** Polomer opisanej gule: (a√3)/2 */
18
+ /** Circumscribed sphere radius: (a√3)/2 */
19
19
  circumRadius: number;
20
- /** Polomer vpisanej gule: a/2 */
20
+ /** Inscribed sphere radius: a/2 */
21
21
  inRadius: number;
22
- /** Polomer strednej gule (dotyka sa hran): (a√2)/2 */
22
+ /** Midsphere radius (touches edges): (a√2)/2 */
23
23
  midRadius: number;
24
24
  }
25
25
 
@@ -28,7 +28,7 @@ export type CubeInput = { [K in keyof CubeResult]?: number } & {
28
28
  };
29
29
 
30
30
  /**
31
- * Vypocita vsetky parametre kocky zo zadaneho jedneho parametra.
31
+ * Compute all cube parameters from any single one.
32
32
  *
33
33
  * @example
34
34
  * cube({ edge: 5 })
@@ -38,11 +38,11 @@ export type CubeInput = { [K in keyof CubeResult]?: number } & {
38
38
  export function cube(input: Partial<CubeResult>): CubeResult;
39
39
 
40
40
  /**
41
- * Vypise vsetky parametre kocky do konzoly a vrati vysledok.
41
+ * Print all cube parameters to the console and return the result.
42
42
  */
43
43
  export function printCube(input: Partial<CubeResult>): CubeResult;
44
44
 
45
- /** Popisy parametrov v slovencine. */
45
+ /** Human-readable parameter descriptions. */
46
46
  export const descriptions: Record<keyof CubeResult, string>;
47
47
 
48
48
  export default cube;
package/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /**
2
2
  * Cube Calculator
3
3
  *
4
- * Vypocita vsetky parametre kocky zo zadaneho jedneho parametra.
4
+ * Compute all cube parameters from any single one.
5
5
  *
6
- * Parametre kocky:
7
- * a - dlzka hrany
8
- * faceDiagonal - uhlopriecka podstavy (steny): a√2
9
- * spaceDiagonal - telesova uhlopriecka: a√3
10
- * surfaceArea - povrch kocky: 6a²
11
- * volume - objem kocky: a³
12
- * faceArea - obsah jednej steny: a²
13
- * perimeter - obvod jednej steny: 4a
14
- * totalEdgeLength - sucet dlzok vsetkych hran: 12a
15
- * circumRadius - polomer opisanej gule: (a√3)/2
16
- * inRadius - polomer vpisanej gule: a/2
17
- * midRadius - polomer strednej gule (dotyka sa hran): (a√2)/2
6
+ * Parameters:
7
+ * edge - edge length
8
+ * faceDiagonal - face diagonal: a√2
9
+ * spaceDiagonal - space diagonal: a√3
10
+ * surfaceArea - surface area: 6a²
11
+ * volume - volume: a³
12
+ * faceArea - face area: a²
13
+ * perimeter - face perimeter: 4a
14
+ * totalEdgeLength - total edge length: 12a
15
+ * circumRadius - circumscribed sphere radius: (a√3)/2
16
+ * inRadius - inscribed sphere radius: a/2
17
+ * midRadius - midsphere radius (touches edges): (a√2)/2
18
18
  */
19
19
 
20
20
  const SQRT2 = Math.sqrt(2);
@@ -51,17 +51,17 @@ const paramToEdge = {
51
51
  };
52
52
 
53
53
  const descriptions = {
54
- edge: "Dlzka hrany",
55
- faceDiagonal: "Uhlopriecka steny (podstavy)",
56
- spaceDiagonal: "Telesova uhlopriecka",
57
- surfaceArea: "Povrch kocky",
58
- volume: "Objem kocky",
59
- faceArea: "Obsah jednej steny",
60
- perimeter: "Obvod jednej steny",
61
- totalEdgeLength: "Sucet dlzok vsetkych hran",
62
- circumRadius: "Polomer opisanej gule",
63
- inRadius: "Polomer vpisanej gule",
64
- midRadius: "Polomer strednej gule",
54
+ edge: "Edge length",
55
+ faceDiagonal: "Face diagonal",
56
+ spaceDiagonal: "Space diagonal",
57
+ surfaceArea: "Surface area",
58
+ volume: "Volume",
59
+ faceArea: "Face area",
60
+ perimeter: "Face perimeter",
61
+ totalEdgeLength: "Total edge length",
62
+ circumRadius: "Circumscribed sphere radius",
63
+ inRadius: "Inscribed sphere radius",
64
+ midRadius: "Midsphere radius",
65
65
  };
66
66
 
67
67
  function cube(input) {
@@ -69,18 +69,18 @@ function cube(input) {
69
69
 
70
70
  if (keys.length === 0) {
71
71
  throw new Error(
72
- `Neznamy parameter. Povolene: ${Object.keys(paramToEdge).join(", ")}`
72
+ `Unknown parameter. Allowed: ${Object.keys(paramToEdge).join(", ")}`
73
73
  );
74
74
  }
75
75
  if (keys.length > 1) {
76
- throw new Error("Zadaj prave jeden parameter.");
76
+ throw new Error("Provide exactly one parameter.");
77
77
  }
78
78
 
79
79
  const key = keys[0];
80
80
  const value = input[key];
81
81
 
82
82
  if (typeof value !== "number" || value <= 0 || !isFinite(value)) {
83
- throw new Error("Hodnota musi byt kladne konecne cislo.");
83
+ throw new Error("Value must be a positive finite number.");
84
84
  }
85
85
 
86
86
  const a = paramToEdge[key](value);
@@ -89,7 +89,7 @@ function cube(input) {
89
89
 
90
90
  function printCube(input) {
91
91
  const result = cube(input);
92
- console.log("=== Parametre kocky ===");
92
+ console.log("=== Cube parameters ===");
93
93
  for (const [key, value] of Object.entries(result)) {
94
94
  const desc = descriptions[key] || key;
95
95
  console.log(` ${desc}: ${value}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jangaba/qube",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Cube calculator – compute all cube parameters from any single one (edge, diagonal, volume, surface area, radius...)",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -34,5 +34,8 @@
34
34
  "repository": {
35
35
  "type": "git",
36
36
  "url": ""
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
37
40
  }
38
41
  }