katanakit-js 2.2.1 → 2.12.9
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 +72 -437
- package/dist/adapters/astro/astro.service.d.ts +103 -15
- package/dist/adapters/astro/astro.service.d.ts.map +1 -1
- package/dist/adapters/astro/astro.service.js +145 -75
- package/dist/adapters/astro/astro.service.js.map +1 -1
- package/dist/adapters/astro/index.d.ts +1 -1
- package/dist/adapters/astro/index.d.ts.map +1 -1
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/rss.service.d.ts +85 -105
- package/dist/adapters/astro/rss.service.d.ts.map +1 -1
- package/dist/adapters/astro/rss.service.js +172 -168
- package/dist/adapters/astro/rss.service.js.map +1 -1
- package/dist/adapters/astro/seo.service.d.ts +10 -0
- package/dist/adapters/astro/seo.service.d.ts.map +1 -0
- package/dist/adapters/astro/seo.service.js +3 -0
- package/dist/adapters/astro/seo.service.js.map +1 -0
- package/dist/adapters/express/app.d.ts +30 -1
- package/dist/adapters/express/app.d.ts.map +1 -1
- package/dist/adapters/express/app.js +31 -3
- package/dist/adapters/express/app.js.map +1 -1
- package/dist/adapters/express/index.d.ts +2 -2
- package/dist/adapters/express/index.d.ts.map +1 -1
- package/dist/adapters/express/index.js +2 -2
- package/dist/adapters/express/index.js.map +1 -1
- package/dist/adapters/express/main.js +2 -2
- package/dist/adapters/express/main.js.map +1 -1
- package/dist/adapters/express/products.controller.d.ts +67 -8
- package/dist/adapters/express/products.controller.d.ts.map +1 -1
- package/dist/adapters/express/products.controller.js +105 -49
- package/dist/adapters/express/products.controller.js.map +1 -1
- package/dist/adapters/express/server.d.ts +37 -13
- package/dist/adapters/express/server.d.ts.map +1 -1
- package/dist/adapters/express/server.js +118 -53
- package/dist/adapters/express/server.js.map +1 -1
- package/dist/adapters/nuxt/nuxt.service.d.ts +8 -6
- package/dist/adapters/nuxt/nuxt.service.d.ts.map +1 -1
- package/dist/adapters/nuxt/nuxt.service.js +34 -10
- package/dist/adapters/nuxt/nuxt.service.js.map +1 -1
- package/dist/adapters/vue/vue.service.d.ts +5 -2
- package/dist/adapters/vue/vue.service.d.ts.map +1 -1
- package/dist/adapters/vue/vue.service.js +41 -7
- package/dist/adapters/vue/vue.service.js.map +1 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/seo-meta.types.d.ts +177 -0
- package/dist/config/seo-meta.types.d.ts.map +1 -0
- package/dist/config/seo-meta.types.js +11 -0
- package/dist/config/seo-meta.types.js.map +1 -0
- package/dist/config/seo.service.d.ts +41 -58
- package/dist/config/seo.service.d.ts.map +1 -1
- package/dist/config/seo.service.js +468 -136
- package/dist/config/seo.service.js.map +1 -1
- package/dist/config/site.config.d.ts +10 -50
- package/dist/config/site.config.d.ts.map +1 -1
- package/dist/config/site.config.js +8 -36
- package/dist/config/site.config.js.map +1 -1
- package/dist/core/index.d.ts +1 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/services/dates.service.d.ts +149 -22
- package/dist/core/services/dates.service.d.ts.map +1 -1
- package/dist/core/services/dates.service.js +201 -54
- package/dist/core/services/dates.service.js.map +1 -1
- package/dist/core/services/error.service.d.ts +32 -20
- package/dist/core/services/error.service.d.ts.map +1 -1
- package/dist/core/services/error.service.js +44 -32
- package/dist/core/services/error.service.js.map +1 -1
- package/dist/core/services/formatter.service.d.ts +245 -35
- package/dist/core/services/formatter.service.d.ts.map +1 -1
- package/dist/core/services/formatter.service.js +281 -57
- package/dist/core/services/formatter.service.js.map +1 -1
- package/dist/core/services/generator.service.d.ts +115 -26
- package/dist/core/services/generator.service.d.ts.map +1 -1
- package/dist/core/services/generator.service.js +191 -56
- package/dist/core/services/generator.service.js.map +1 -1
- package/dist/core/services/geometry.service.d.ts +369 -39
- package/dist/core/services/geometry.service.d.ts.map +1 -1
- package/dist/core/services/geometry.service.js +424 -66
- package/dist/core/services/geometry.service.js.map +1 -1
- package/dist/core/services/http.service.d.ts +244 -21
- package/dist/core/services/http.service.d.ts.map +1 -1
- package/dist/core/services/http.service.js +419 -98
- package/dist/core/services/http.service.js.map +1 -1
- package/dist/core/services/logger.service.d.ts +95 -29
- package/dist/core/services/logger.service.d.ts.map +1 -1
- package/dist/core/services/logger.service.js +167 -41
- package/dist/core/services/logger.service.js.map +1 -1
- package/dist/core/services/reactive.service.d.ts +146 -19
- package/dist/core/services/reactive.service.d.ts.map +1 -1
- package/dist/core/services/reactive.service.js +278 -137
- package/dist/core/services/reactive.service.js.map +1 -1
- package/dist/core/services/timing.service.d.ts +142 -20
- package/dist/core/services/timing.service.d.ts.map +1 -1
- package/dist/core/services/timing.service.js +324 -185
- package/dist/core/services/timing.service.js.map +1 -1
- package/dist/core/services/utils.service.d.ts +228 -43
- package/dist/core/services/utils.service.d.ts.map +1 -1
- package/dist/core/services/utils.service.js +305 -125
- package/dist/core/services/utils.service.js.map +1 -1
- package/dist/infrastructure/dom/dom.service.d.ts +307 -44
- package/dist/infrastructure/dom/dom.service.d.ts.map +1 -1
- package/dist/infrastructure/dom/dom.service.js +408 -129
- package/dist/infrastructure/dom/dom.service.js.map +1 -1
- package/dist/infrastructure/index.d.ts +0 -3
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +0 -3
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/infrastructure/observer/observer.service.d.ts +124 -31
- package/dist/infrastructure/observer/observer.service.d.ts.map +1 -1
- package/dist/infrastructure/observer/observer.service.js +227 -131
- package/dist/infrastructure/observer/observer.service.js.map +1 -1
- package/dist/infrastructure/sensors/sensors.service.d.ts +154 -22
- package/dist/infrastructure/sensors/sensors.service.d.ts.map +1 -1
- package/dist/infrastructure/sensors/sensors.service.js +264 -112
- package/dist/infrastructure/sensors/sensors.service.js.map +1 -1
- package/dist/infrastructure/storage/storage.service.d.ts +123 -45
- package/dist/infrastructure/storage/storage.service.d.ts.map +1 -1
- package/dist/infrastructure/storage/storage.service.js +236 -66
- package/dist/infrastructure/storage/storage.service.js.map +1 -1
- package/dist/infrastructure/theme/theme.service.d.ts +93 -29
- package/dist/infrastructure/theme/theme.service.d.ts.map +1 -1
- package/dist/infrastructure/theme/theme.service.js +198 -96
- package/dist/infrastructure/theme/theme.service.js.map +1 -1
- package/dist/infrastructure/viewport/viewport.service.d.ts +233 -35
- package/dist/infrastructure/viewport/viewport.service.d.ts.map +1 -1
- package/dist/infrastructure/viewport/viewport.service.js +358 -139
- package/dist/infrastructure/viewport/viewport.service.js.map +1 -1
- package/dist/infrastructure/worker/worker.service.d.ts +84 -38
- package/dist/infrastructure/worker/worker.service.d.ts.map +1 -1
- package/dist/infrastructure/worker/worker.service.js +234 -133
- package/dist/infrastructure/worker/worker.service.js.map +1 -1
- package/dist/prisma/index.d.ts +2 -0
- package/dist/prisma/index.d.ts.map +1 -0
- package/dist/prisma/index.js +2 -0
- package/dist/prisma/index.js.map +1 -0
- package/dist/prisma/schema.json +11 -33
- package/dist/prisma/use-prisma.d.ts +68 -0
- package/dist/prisma/use-prisma.d.ts.map +1 -0
- package/dist/prisma/use-prisma.js +82 -0
- package/dist/prisma/use-prisma.js.map +1 -0
- package/dist/types/index.d.ts +20 -12
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +124 -125
- package/CHANGELOG.md +0 -101
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper: formats a numeric geometry result via `Intl`.
|
|
3
|
+
* Stateless — input → formatted string only.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The numeric value to format.
|
|
6
|
+
* @param options - Formatting options (locale, digits, unit).
|
|
7
|
+
* @returns The formatted string, optionally with a unit suffix.
|
|
8
|
+
*/
|
|
1
9
|
function formatGeometry(value, options = {}) {
|
|
2
10
|
const { locale = "en", digits = 2, unit } = options;
|
|
3
11
|
const formatted = new Intl.NumberFormat(locale, {
|
|
@@ -6,95 +14,445 @@ function formatGeometry(value, options = {}) {
|
|
|
6
14
|
}).format(value);
|
|
7
15
|
return unit ? `${formatted} ${unit}` : formatted;
|
|
8
16
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Pure area calculations for geometric shapes.
|
|
19
|
+
* All functions are stateless — input → formatted string only.
|
|
20
|
+
*/
|
|
21
|
+
const area = {
|
|
22
|
+
/**
|
|
23
|
+
* Calculates the area of a rectangle.
|
|
24
|
+
*
|
|
25
|
+
* @param width - The width of the rectangle.
|
|
26
|
+
* @param height - The height of the rectangle.
|
|
27
|
+
* @param options - Optional formatting options.
|
|
28
|
+
* @returns The formatted area string.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
33
|
+
*
|
|
34
|
+
* GeometryUtils.area.useRectangle(5, 10); // "50.00"
|
|
35
|
+
* GeometryUtils.area.useRectangle(5, 10, { unit: "m²" }); // "50.00 m²"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
useRectangle(width, height, options) {
|
|
13
39
|
return formatGeometry(width * height, options);
|
|
14
|
-
}
|
|
15
|
-
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Calculates the area of a square.
|
|
43
|
+
*
|
|
44
|
+
* @param side - The side length of the square.
|
|
45
|
+
* @param options - Optional formatting options.
|
|
46
|
+
* @returns The formatted area string.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
51
|
+
*
|
|
52
|
+
* GeometryUtils.area.useSquare(4); // "16.00"
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
useSquare(side, options) {
|
|
16
56
|
return formatGeometry(side ** 2, options);
|
|
17
|
-
}
|
|
18
|
-
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Calculates the area of a triangle.
|
|
60
|
+
*
|
|
61
|
+
* @param base - The base length of the triangle.
|
|
62
|
+
* @param height - The height of the triangle.
|
|
63
|
+
* @param options - Optional formatting options.
|
|
64
|
+
* @returns The formatted area string.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
69
|
+
*
|
|
70
|
+
* GeometryUtils.area.useTriangle(6, 4); // "12.00"
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
useTriangle(base, height, options) {
|
|
19
74
|
return formatGeometry((base * height) / 2, options);
|
|
20
|
-
}
|
|
21
|
-
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Calculates the area of a circle.
|
|
78
|
+
*
|
|
79
|
+
* @param radius - The radius of the circle.
|
|
80
|
+
* @param options - Optional formatting options.
|
|
81
|
+
* @returns The formatted area string.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
86
|
+
*
|
|
87
|
+
* GeometryUtils.area.useCircle(5); // "78.54"
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
useCircle(radius, options) {
|
|
22
91
|
return formatGeometry(Math.PI * radius ** 2, options);
|
|
23
|
-
}
|
|
24
|
-
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Calculates the area of a trapezoid.
|
|
95
|
+
*
|
|
96
|
+
* @param parallelSide1 - The length of the first parallel side.
|
|
97
|
+
* @param parallelSide2 - The length of the second parallel side.
|
|
98
|
+
* @param height - The height between parallel sides.
|
|
99
|
+
* @param options - Optional formatting options.
|
|
100
|
+
* @returns The formatted area string.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
105
|
+
*
|
|
106
|
+
* GeometryUtils.area.useTrapezoid(3, 5, 4); // "16.00"
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
useTrapezoid(parallelSide1, parallelSide2, height, options) {
|
|
25
110
|
return formatGeometry(((parallelSide1 + parallelSide2) * height) / 2, options);
|
|
26
|
-
}
|
|
27
|
-
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Calculates the area of a regular hexagon.
|
|
114
|
+
*
|
|
115
|
+
* @param side - The side length of the hexagon.
|
|
116
|
+
* @param options - Optional formatting options.
|
|
117
|
+
* @returns The formatted area string.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
122
|
+
*
|
|
123
|
+
* GeometryUtils.area.useHexagon(3); // "23.38"
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
useHexagon(side, options) {
|
|
28
127
|
return formatGeometry(((3 * Math.sqrt(3)) / 2) * side ** 2, options);
|
|
29
|
-
}
|
|
30
|
-
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Calculates the area of an ellipse.
|
|
131
|
+
*
|
|
132
|
+
* @param semiMajor - The semi-major axis length.
|
|
133
|
+
* @param semiMinor - The semi-minor axis length.
|
|
134
|
+
* @param options - Optional formatting options.
|
|
135
|
+
* @returns The formatted area string.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
140
|
+
*
|
|
141
|
+
* GeometryUtils.area.useEllipse(5, 3); // "47.12"
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
useEllipse(semiMajor, semiMinor, options) {
|
|
31
145
|
return formatGeometry(Math.PI * semiMajor * semiMinor, options);
|
|
32
|
-
}
|
|
33
|
-
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Calculates the area of a parallelogram.
|
|
149
|
+
*
|
|
150
|
+
* @param base - The base length of the parallelogram.
|
|
151
|
+
* @param height - The height of the parallelogram.
|
|
152
|
+
* @param options - Optional formatting options.
|
|
153
|
+
* @returns The formatted area string.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
158
|
+
*
|
|
159
|
+
* GeometryUtils.area.useParallelogram(6, 4); // "24.00"
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
useParallelogram(base, height, options) {
|
|
34
163
|
return formatGeometry(base * height, options);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Pure perimeter calculations for geometric shapes.
|
|
168
|
+
* All functions are stateless — input → formatted string only.
|
|
169
|
+
*/
|
|
170
|
+
const perimeter = {
|
|
171
|
+
/**
|
|
172
|
+
* Calculates the perimeter of a rectangle.
|
|
173
|
+
*
|
|
174
|
+
* @param width - The width of the rectangle.
|
|
175
|
+
* @param height - The height of the rectangle.
|
|
176
|
+
* @param options - Optional formatting options.
|
|
177
|
+
* @returns The formatted perimeter string.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
182
|
+
*
|
|
183
|
+
* GeometryUtils.perimeter.useRectangle(5, 10); // "30.00"
|
|
184
|
+
* GeometryUtils.perimeter.useRectangle(5, 10, { unit: "m" }); // "30.00 m"
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
useRectangle(width, height, options) {
|
|
41
188
|
return formatGeometry(2 * (width + height), options);
|
|
42
|
-
}
|
|
43
|
-
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* Calculates the perimeter of a square.
|
|
192
|
+
*
|
|
193
|
+
* @param side - The side length of the square.
|
|
194
|
+
* @param options - Optional formatting options.
|
|
195
|
+
* @returns The formatted perimeter string.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
200
|
+
*
|
|
201
|
+
* GeometryUtils.perimeter.useSquare(4); // "16.00"
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
useSquare(side, options) {
|
|
44
205
|
return formatGeometry(4 * side, options);
|
|
45
|
-
}
|
|
46
|
-
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* Calculates the perimeter of a triangle.
|
|
209
|
+
*
|
|
210
|
+
* @param side1 - The length of the first side.
|
|
211
|
+
* @param side2 - The length of the second side.
|
|
212
|
+
* @param side3 - The length of the third side.
|
|
213
|
+
* @param options - Optional formatting options.
|
|
214
|
+
* @returns The formatted perimeter string.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
219
|
+
*
|
|
220
|
+
* GeometryUtils.perimeter.useTriangle(3, 4, 5); // "12.00"
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
useTriangle(side1, side2, side3, options) {
|
|
47
224
|
return formatGeometry(side1 + side2 + side3, options);
|
|
48
|
-
}
|
|
49
|
-
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* Calculates the perimeter (circumference) of a circle.
|
|
228
|
+
*
|
|
229
|
+
* @param radius - The radius of the circle.
|
|
230
|
+
* @param options - Optional formatting options.
|
|
231
|
+
* @returns The formatted perimeter string.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
236
|
+
*
|
|
237
|
+
* GeometryUtils.perimeter.useCircle(5); // "31.42"
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
useCircle(radius, options) {
|
|
50
241
|
return formatGeometry(2 * Math.PI * radius, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Calculates the perimeter of a regular hexagon.
|
|
245
|
+
*
|
|
246
|
+
* @param side - The side length of the hexagon.
|
|
247
|
+
* @param options - Optional formatting options.
|
|
248
|
+
* @returns The formatted perimeter string.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
253
|
+
*
|
|
254
|
+
* GeometryUtils.perimeter.useHexagon(3); // "18.00"
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
useHexagon(side, options) {
|
|
53
258
|
return formatGeometry(6 * side, options);
|
|
54
|
-
}
|
|
55
|
-
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* Calculates the perimeter of a trapezoid.
|
|
262
|
+
*
|
|
263
|
+
* @param side1 - The length of the first side.
|
|
264
|
+
* @param side2 - The length of the second side.
|
|
265
|
+
* @param side3 - The length of the third side.
|
|
266
|
+
* @param side4 - The length of the fourth side.
|
|
267
|
+
* @param options - Optional formatting options.
|
|
268
|
+
* @returns The formatted perimeter string.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
273
|
+
*
|
|
274
|
+
* GeometryUtils.perimeter.useTrapezoid(3, 5, 4, 4); // "16.00"
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
useTrapezoid(side1, side2, side3, side4, options) {
|
|
56
278
|
return formatGeometry(side1 + side2 + side3 + side4, options);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* Calculates the perimeter of an ellipse using Ramanujan's approximation II.
|
|
282
|
+
*
|
|
283
|
+
* @param semiMajor - The semi-major axis length.
|
|
284
|
+
* @param semiMinor - The semi-minor axis length.
|
|
285
|
+
* @param options - Optional formatting options.
|
|
286
|
+
* @returns The formatted perimeter string.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
291
|
+
*
|
|
292
|
+
* GeometryUtils.perimeter.useEllipse(5, 3); // "25.53"
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
useEllipse(semiMajor, semiMinor, options) {
|
|
296
|
+
const a = Math.abs(semiMajor);
|
|
297
|
+
const b = Math.abs(semiMinor);
|
|
298
|
+
const sum = a + b;
|
|
299
|
+
if (sum === 0) {
|
|
300
|
+
return formatGeometry(0, options);
|
|
301
|
+
}
|
|
302
|
+
// Ramanujan approximation II — stable when a === b (circle).
|
|
303
|
+
const h = ((a - b) / sum) ** 2;
|
|
304
|
+
const perimeterValue = Math.PI * sum * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h)));
|
|
305
|
+
return formatGeometry(perimeterValue, options);
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* Calculates the perimeter of a parallelogram.
|
|
309
|
+
*
|
|
310
|
+
* @param side1 - The length of the first side.
|
|
311
|
+
* @param side2 - The length of the second side.
|
|
312
|
+
* @param options - Optional formatting options.
|
|
313
|
+
* @returns The formatted perimeter string.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
318
|
+
*
|
|
319
|
+
* GeometryUtils.perimeter.useParallelogram(5, 3); // "16.00"
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
useParallelogram(side1, side2, options) {
|
|
66
323
|
return formatGeometry(2 * (side1 + side2), options);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Pure volume calculations for 3D geometric shapes.
|
|
328
|
+
* All functions are stateless — input → formatted string only.
|
|
329
|
+
*/
|
|
330
|
+
const volume = {
|
|
331
|
+
/**
|
|
332
|
+
* Calculates the volume of a cube.
|
|
333
|
+
*
|
|
334
|
+
* @param side - The side length of the cube.
|
|
335
|
+
* @param options - Optional formatting options.
|
|
336
|
+
* @returns The formatted volume string.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
341
|
+
*
|
|
342
|
+
* GeometryUtils.volume.useCube(3); // "27.00"
|
|
343
|
+
* GeometryUtils.volume.useCube(3, { unit: "m³" }); // "27.00 m³"
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
useCube(side, options) {
|
|
73
347
|
return formatGeometry(side ** 3, options);
|
|
74
|
-
}
|
|
75
|
-
|
|
348
|
+
},
|
|
349
|
+
/**
|
|
350
|
+
* Calculates the volume of a box (rectangular prism).
|
|
351
|
+
*
|
|
352
|
+
* @param length - The length of the box.
|
|
353
|
+
* @param width - The width of the box.
|
|
354
|
+
* @param height - The height of the box.
|
|
355
|
+
* @param options - Optional formatting options.
|
|
356
|
+
* @returns The formatted volume string.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
361
|
+
*
|
|
362
|
+
* GeometryUtils.volume.useBox(2, 3, 4); // "24.00"
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
useBox(length, width, height, options) {
|
|
76
366
|
return formatGeometry(length * width * height, options);
|
|
77
|
-
}
|
|
78
|
-
|
|
367
|
+
},
|
|
368
|
+
/**
|
|
369
|
+
* Calculates the volume of a sphere.
|
|
370
|
+
*
|
|
371
|
+
* @param radius - The radius of the sphere.
|
|
372
|
+
* @param options - Optional formatting options.
|
|
373
|
+
* @returns The formatted volume string.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
378
|
+
*
|
|
379
|
+
* GeometryUtils.volume.useSphere(3); // "113.10"
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
useSphere(radius, options) {
|
|
79
383
|
return formatGeometry((4 / 3) * Math.PI * radius ** 3, options);
|
|
80
|
-
}
|
|
81
|
-
|
|
384
|
+
},
|
|
385
|
+
/**
|
|
386
|
+
* Calculates the volume of a cylinder.
|
|
387
|
+
*
|
|
388
|
+
* @param radius - The radius of the cylinder base.
|
|
389
|
+
* @param height - The height of the cylinder.
|
|
390
|
+
* @param options - Optional formatting options.
|
|
391
|
+
* @returns The formatted volume string.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
396
|
+
*
|
|
397
|
+
* GeometryUtils.volume.useCylinder(3, 5); // "141.37"
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
useCylinder(radius, height, options) {
|
|
82
401
|
return formatGeometry(Math.PI * radius ** 2 * height, options);
|
|
83
|
-
}
|
|
84
|
-
|
|
402
|
+
},
|
|
403
|
+
/**
|
|
404
|
+
* Calculates the volume of a cone.
|
|
405
|
+
*
|
|
406
|
+
* @param radius - The radius of the cone base.
|
|
407
|
+
* @param height - The height of the cone.
|
|
408
|
+
* @param options - Optional formatting options.
|
|
409
|
+
* @returns The formatted volume string.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
414
|
+
*
|
|
415
|
+
* GeometryUtils.volume.useCone(3, 5); // "47.12"
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
useCone(radius, height, options) {
|
|
85
419
|
return formatGeometry((1 / 3) * Math.PI * radius ** 2 * height, options);
|
|
86
|
-
}
|
|
87
|
-
|
|
420
|
+
},
|
|
421
|
+
/**
|
|
422
|
+
* Calculates the volume of a pyramid.
|
|
423
|
+
*
|
|
424
|
+
* @param baseArea - The area of the pyramid base.
|
|
425
|
+
* @param height - The height of the pyramid.
|
|
426
|
+
* @param options - Optional formatting options.
|
|
427
|
+
* @returns The formatted volume string.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
432
|
+
*
|
|
433
|
+
* GeometryUtils.volume.usePyramid(12, 5); // "20.00"
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
usePyramid(baseArea, height, options) {
|
|
88
437
|
return formatGeometry((1 / 3) * baseArea * height, options);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
438
|
+
},
|
|
439
|
+
};
|
|
91
440
|
/**
|
|
92
|
-
* Consolidated geometry utilities namespace.
|
|
93
|
-
* Groups area, perimeter and volume calculations.
|
|
441
|
+
* Consolidated pure geometry utilities namespace.
|
|
442
|
+
* Groups area, perimeter and volume calculations (no shared mutable state).
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```ts
|
|
446
|
+
* import { GeometryUtils } from "katanakit-js";
|
|
447
|
+
*
|
|
448
|
+
* GeometryUtils.area.useCircle(5); // "78.54"
|
|
449
|
+
* GeometryUtils.perimeter.useCircle(5); // "31.42"
|
|
450
|
+
* GeometryUtils.volume.useSphere(3); // "113.10"
|
|
451
|
+
* ```
|
|
94
452
|
*/
|
|
95
453
|
export const GeometryUtils = {
|
|
96
|
-
area
|
|
97
|
-
perimeter
|
|
98
|
-
volume
|
|
454
|
+
area,
|
|
455
|
+
perimeter,
|
|
456
|
+
volume,
|
|
99
457
|
};
|
|
100
458
|
//# sourceMappingURL=geometry.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.service.js","sourceRoot":"","sources":["../../../src/core/services/geometry.service.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,KAAa,EAAE,OAAO,GAA0B,EAAE;IACzE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QAC/C,qBAAqB,EAAE,MAAM;QAC7B,qBAAqB,EAAE,MAAM;KAC7B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjB,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"geometry.service.js","sourceRoot":"","sources":["../../../src/core/services/geometry.service.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,KAAa,EAAE,OAAO,GAA0B,EAAE;IACzE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QAC/C,qBAAqB,EAAE,MAAM;QAC7B,qBAAqB,EAAE,MAAM;KAC7B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjB,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,IAAI,GAAG;IACZ;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,KAAa,EAAE,MAAc,EAAE,OAA+B;QAC1E,OAAO,cAAc,CAAC,KAAK,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,IAAY,EAAE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