@carlsebastian/jsu 1.0.50 → 1.1.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 (52) hide show
  1. package/README.MD +1 -1
  2. package/global.js +1 -1
  3. package/package.json +10 -2
  4. package/src/docs/api/api.md +3 -2
  5. package/src/docs/custom/custom.md +13 -33
  6. package/src/docs/custom/error/builder/builder.md +24 -0
  7. package/src/docs/custom/error/constructor/error.constructor.md +33 -0
  8. package/src/docs/custom/error/constructor/opts/argumentError.md +78 -0
  9. package/src/docs/custom/error/constructor/opts/indexOutOfBounds.md +77 -0
  10. package/src/docs/custom/error/constructor/opts/invalidPropertyError.md +83 -0
  11. package/src/docs/custom/error/constructor/opts/missingParameterError.md +75 -0
  12. package/src/docs/custom/error/constructor/opts/missingPropertyError.md +81 -0
  13. package/src/docs/custom/error/constructor/opts/noSuchElementTagError.md +81 -0
  14. package/src/docs/custom/error/constructor/opts/notSupportedError.md +81 -0
  15. package/src/docs/custom/error/constructor/opts/unknownPropertyError.md +82 -0
  16. package/src/docs/custom/error/error.md +36 -0
  17. package/src/docs/custom/utils/clamp.md +8 -6
  18. package/src/docs/custom/utils/constructorOrTypeOf.md +8 -6
  19. package/src/docs/custom/utils/generator/generator.md +8 -6
  20. package/src/docs/custom/utils/generator/methods/generator.newToken.md +11 -8
  21. package/src/docs/custom/utils/generator/methods/generator.randomCharacters.md +11 -8
  22. package/src/docs/custom/utils/generator/methods/generator.randomInteger.md +11 -8
  23. package/src/docs/custom/utils/nameOf.md +8 -6
  24. package/src/types/api/api.d.ts +27 -9
  25. package/src/types/arithmetic/arithmetic.d.ts +281 -0
  26. package/src/types/custom/error/builder/error.builder.d.ts +1 -1
  27. package/src/types/custom/error/constructor/error.custom.d.ts +24 -8
  28. package/src/types/custom/error/constructor/error.meta.d.ts +6 -6
  29. package/src/types/custom/utils/custom.utils.d.ts +83 -0
  30. package/src/types/global.d.ts +5 -3
  31. package/src/utils/arithmetic/arithmetic.js +20 -0
  32. package/src/utils/arithmetic/operations/operation.divide.js +78 -0
  33. package/src/utils/arithmetic/operations/operation.multiply.js +75 -0
  34. package/src/utils/arithmetic/operations/operation.subtract.js +64 -0
  35. package/src/utils/arithmetic/operations/operation.sum.js +65 -0
  36. package/src/utils/custom/error/builder/error.builder.js +3 -3
  37. package/src/utils/custom/error/error.js +2 -2
  38. package/src/utils/custom/utils/custom.utils.js +68 -4
  39. package/src/utils/custom/utils/generator/generator.js +4 -4
  40. package/src/utils/dom/attr/attr.class.js +4 -4
  41. package/src/utils/dom/attr/attr.id.js +3 -3
  42. package/src/utils/dom/attr/attr.style.js +5 -5
  43. package/src/utils/dom/element/create/element.create.js +14 -14
  44. package/src/utils/dom/element/getElementBy/dom.getElementBy.js +6 -6
  45. package/src/utils/dom/element/query/dom.query.js +3 -3
  46. package/src/utils/dom/element/tag-verifier/verifier.js +5 -5
  47. package/src/utils/dom/lifecycle/mount.js +3 -3
  48. package/src/utils/dom/lifecycle/unmount.js +2 -2
  49. package/src/utils/storage/local/storage.local.js +3 -3
  50. package/src/utils/storage/session/storage.session.js +3 -3
  51. package/src/utils/storage/storage.js +2 -2
  52. package/src/utils/variables.js +13 -7
@@ -0,0 +1,281 @@
1
+ interface ArithmeticAPI {
2
+ /**
3
+ * Accumulates the total divided value of the first and second numerical values.
4
+ *
5
+ * ***Note***:
6
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
7
+ *
8
+ * @param num1 - The first or primary base numerical value of this operation.
9
+ * @param num2 - The second numerical value to divide with primary value.
10
+ * @returns The total accumulated result of this operation.
11
+ */
12
+ Divide(num1: number, num2: number): number;
13
+
14
+ /**
15
+ * Accumulates the total divided value of the first, second, and third numerical values.
16
+ *
17
+ * ***Note***:
18
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
19
+ *
20
+ * @param num1 - The first or primary base numerical value of this operation.
21
+ * @param num2 - The second numerical value to divide with primary value.
22
+ * @param num3 - The third numerical value to divide with the given first 2 numerical values.
23
+ * @returns The total accumulated result of this operation.
24
+ */
25
+ Divide(num1: number, num2: number, num3: number): number;
26
+
27
+ /**
28
+ * Accumulates the total divided value of the first, second, third, and fourth numerical values.
29
+ *
30
+ * ***Note***:
31
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
32
+ *
33
+ * @param num1 - The first or primary base numerical value of this operation.
34
+ * @param num2 - The second numerical value to divide with primary value.
35
+ * @param num3 - The third numerical value to divide with the given first 2 numerical values.
36
+ * @param num4 - The fourth numerical value to divide with the given first 3 numerical values.
37
+ * @returns The total accumulated result of this operation.
38
+ */
39
+ Divide(num1: number, num2: number, num3: number, num4: number): number;
40
+
41
+ /**
42
+ * Accumulates the total divided value of the first, second, third, and fourth numerical values.
43
+ *
44
+ * ***Note***:
45
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
46
+ *
47
+ * @param num1 - The first or primary base numerical value of this operation.
48
+ * @param num2 - The second numerical value to divide with primary value.
49
+ * @param num3 - The third numerical value to divide with the given first 2 numerical values.
50
+ * @param num4 - The fourth numerical value to divide with the given first 3 numerical values.
51
+ * @returns The total accumulated result of this operation.
52
+ */
53
+ Divide(num1: number, num2: number, num3: number, num4: number): number;
54
+
55
+ /**
56
+ * Accumulates the total divided value of the first, second, third, fourth, and fifth numerical values.
57
+ *
58
+ * ***Note***:
59
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
60
+ *
61
+ * @param num1 - The first or primary base numerical value of this operation.
62
+ * @param num2 - The second numerical value to divide with primary value.
63
+ * @param num3 - The third numerical value to divide with the given first 2 numerical values.
64
+ * @param num4 - The fourth numerical value to divide with the given first 3 numerical values.
65
+ * @param num5 - The fifth numerical value to divide with the other given 4 numerical values.
66
+ * @returns The total accumulated result of this operation.
67
+ */
68
+ Divide(num1: number, num2: number, num3: number, num4: number, num5: number): number;
69
+
70
+ /**
71
+ * Accumulates the total divided value of the given collection of numerical values.
72
+ *
73
+ * ***Note***:
74
+ * - Using a zero (`0`) to divide other given numerical values would always resulted to `NaN`.
75
+ *
76
+ * @param nums - The collection of numerical values to divide.
77
+ * @returns The total accumulated result of this operation.
78
+ */
79
+ Divide(...nums: number[]): number;
80
+
81
+ /**
82
+ * Accumulates the total multiplied value of the first and second numerical values.
83
+ *
84
+ * ***Note***:
85
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
86
+ *
87
+ * @param num1 - The first or primary base numerical value of this operation.
88
+ * @param num2 - The second numerical value to multiply with primary value.
89
+ * @returns The total accumulated result of this operation.
90
+ */
91
+ Multiply(num1: number, num2: number): number;
92
+
93
+ /**
94
+ * Accumulates the total multiplied value of the first, second, and third numerical values.
95
+ *
96
+ * ***Note***:
97
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
98
+ *
99
+ * @param num1 - The first or primary base numerical value of this operation.
100
+ * @param num2 - The second numerical value to multiply with primary value.
101
+ * @param num3 - The third numerical value to multiply with the given first 2 numerical values.
102
+ * @returns The total accumulated result of this operation.
103
+ */
104
+ Multiply(num1: number, num2: number, num3: number): number;
105
+
106
+ /**
107
+ * Accumulates the total multiplied value of the first, second, third, and fourth numerical values.
108
+ *
109
+ * ***Note***:
110
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
111
+ *
112
+ * @param num1 - The first or primary base numerical value of this operation.
113
+ * @param num2 - The second numerical value to multiply with primary value.
114
+ * @param num3 - The third numerical value to multiply with the given first 2 numerical values.
115
+ * @param num4 - The fourth numerical value to multiply with the given first 3 numerical values.
116
+ * @returns The total accumulated result of this operation.
117
+ */
118
+ Multiply(num1: number, num2: number, num3: number, num4: number): number;
119
+
120
+ /**
121
+ * Accumulates the total multiplied value of the first, second, third, and fourth numerical values.
122
+ *
123
+ * ***Note***:
124
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
125
+ *
126
+ * @param num1 - The first or primary base numerical value of this operation.
127
+ * @param num2 - The second numerical value to multiply with primary value.
128
+ * @param num3 - The third numerical value to multiply with the given first 2 numerical values.
129
+ * @param num4 - The fourth numerical value to multiply with the given first 3 numerical values.
130
+ * @returns The total accumulated result of this operation.
131
+ */
132
+ Multiply(num1: number, num2: number, num3: number, num4: number): number;
133
+
134
+ /**
135
+ * Accumulates the total multiplied value of the first, second, third, fourth, and fifth numerical values.
136
+ *
137
+ * ***Note***:
138
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
139
+ *
140
+ * @param num1 - The first or primary base numerical value of this operation.
141
+ * @param num2 - The second numerical value to multiply with primary value.
142
+ * @param num3 - The third numerical value to multiply with the given first 2 numerical values.
143
+ * @param num4 - The fourth numerical value to multiply with the given first 3 numerical values.
144
+ * @param num5 - The fifth numerical value to multiply with the other given 4 numerical values.
145
+ * @returns The total accumulated result of this operation.
146
+ */
147
+ Multiply(num1: number, num2: number, num3: number, num4: number, num5: number): number;
148
+
149
+ /**
150
+ * Accumulates the total multiplied value of the given collection of numerical values.
151
+ *
152
+ * ***Note***:
153
+ * - Using a zero (`0`) to multiply other given numerical values would always resulted to (`0`).
154
+ *
155
+ * @param nums - The collection of numerical values to multiply.
156
+ * @returns The total accumulated result of this operation.
157
+ */
158
+ Multiply(...nums: number[]): number;
159
+
160
+ /**
161
+ * Accumulates the total subtracted value of the first and second numerical values.
162
+ *
163
+ * @param num1 - The first or primary base numerical value of this operation.
164
+ * @param num2 - The second numerical value to subtract with primary value.
165
+ * @returns The total accumulated result of this operation.
166
+ */
167
+ Subtract(num1: number, num2: number): number;
168
+
169
+ /**
170
+ * Accumulates the total subtracted value of the first, second, and third numerical values.
171
+ *
172
+ * @param num1 - The first or primary base numerical value of this operation.
173
+ * @param num2 - The second numerical value to subtract with primary value.
174
+ * @param num3 - The third numerical value to subtract with the given first 2 numerical values.
175
+ * @returns The total accumulated result of this operation.
176
+ */
177
+ Subtract(num1: number, num2: number, num3: number): number;
178
+
179
+ /**
180
+ * Accumulates the total subtracted value of the first, second, third, and fourth numerical values.
181
+ *
182
+ * @param num1 - The first or primary base numerical value of this operation.
183
+ * @param num2 - The second numerical value to subtract with primary value.
184
+ * @param num3 - The third numerical value to subtract with the given first 2 numerical values.
185
+ * @param num4 - The fourth numerical value to subtract with the given first 3 numerical values.
186
+ * @returns The total accumulated result of this operation.
187
+ */
188
+ Subtract(num1: number, num2: number, num3: number, num4: number): number;
189
+
190
+ /**
191
+ * Accumulates the total subtracted value of the first, second, third, and fourth numerical values.
192
+ *
193
+ * @param num1 - The first or primary base numerical value of this operation.
194
+ * @param num2 - The second numerical value to subtract with primary value.
195
+ * @param num3 - The third numerical value to subtract with the given first 2 numerical values.
196
+ * @param num4 - The fourth numerical value to subtract with the given first 3 numerical values.
197
+ * @returns The total accumulated result of this operation.
198
+ */
199
+ Subtract(num1: number, num2: number, num3: number, num4: number): number;
200
+
201
+ /**
202
+ * Accumulates the total subtracted value of the first, second, third, fourth, and fifth numerical values.
203
+ *
204
+ * @param num1 - The first or primary base numerical value of this operation.
205
+ * @param num2 - The second numerical value to subtract with primary value.
206
+ * @param num3 - The third numerical value to subtract with the given first 2 numerical values.
207
+ * @param num4 - The fourth numerical value to subtract with the given first 3 numerical values.
208
+ * @param num5 - The fifth numerical value to subtract with the other given 4 numerical values.
209
+ * @returns The total accumulated result of this operation.
210
+ */
211
+ Subtract(num1: number, num2: number, num3: number, num4: number, num5: number): number;
212
+
213
+ /**
214
+ * Accumulates the total subtracted value of the given collection of numerical values.
215
+ *
216
+ * @param nums - The collection of numerical values to subtract.
217
+ * @returns The total accumulated result of this operation.
218
+ */
219
+ Subtract(...nums: number[]): number;
220
+
221
+ /**
222
+ * Accumulates the total summed value of the first and second numerical values.
223
+ *
224
+ * @param num1 - The first or primary base numerical value of this operation.
225
+ * @param num2 - The second numerical value to sum with primary value.
226
+ * @returns The total accumulated result of this operation.
227
+ */
228
+ Sum(num1: number, num2: number): number;
229
+
230
+ /**
231
+ * Accumulates the total summed value of the first, second, and third numerical values.
232
+ *
233
+ * @param num1 - The first or primary base numerical value of this operation.
234
+ * @param num2 - The second numerical value to sum with primary value.
235
+ * @param num3 - The third numerical value to sum with the given first 2 numerical values.
236
+ * @returns The total accumulated result of this operation.
237
+ */
238
+ Sum(num1: number, num2: number, num3: number): number;
239
+
240
+ /**
241
+ * Accumulates the total summed value of the first, second, third, and fourth numerical values.
242
+ *
243
+ * @param num1 - The first or primary base numerical value of this operation.
244
+ * @param num2 - The second numerical value to sum with primary value.
245
+ * @param num3 - The third numerical value to sum with the given first 2 numerical values.
246
+ * @param num4 - The fourth numerical value to sum with the given first 3 numerical values.
247
+ * @returns The total accumulated result of this operation.
248
+ */
249
+ Sum(num1: number, num2: number, num3: number, num4: number): number;
250
+
251
+ /**
252
+ * Accumulates the total summed value of the first, second, third, and fourth numerical values.
253
+ *
254
+ * @param num1 - The first or primary base numerical value of this operation.
255
+ * @param num2 - The second numerical value to sum with primary value.
256
+ * @param num3 - The third numerical value to sum with the given first 2 numerical values.
257
+ * @param num4 - The fourth numerical value to sum with the given first 3 numerical values.
258
+ * @returns The total accumulated result of this operation.
259
+ */
260
+ Sum(num1: number, num2: number, num3: number, num4: number): number;
261
+
262
+ /**
263
+ * Accumulates the total summed value of the first, second, third, fourth, and fifth numerical values.
264
+ *
265
+ * @param num1 - The first or primary base numerical value of this operation.
266
+ * @param num2 - The second numerical value to sum with primary value.
267
+ * @param num3 - The third numerical value to sum with the given first 2 numerical values.
268
+ * @param num4 - The fourth numerical value to sum with the given first 3 numerical values.
269
+ * @param num5 - The fifth numerical value to sum with the other given 4 numerical values.
270
+ * @returns The total accumulated result of this operation.
271
+ */
272
+ Sum(num1: number, num2: number, num3: number, num4: number, num5: number): number;
273
+
274
+ /**
275
+ * Accumulates the total summed value of the given collection of numerical values.
276
+ *
277
+ * @param nums - The collection of numerical values to sum.
278
+ * @returns The total accumulated result of this operation.
279
+ */
280
+ Sum(...nums: number[]): number;
281
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A collection of customized error emitter contents for `ErrorConstructorAPI`.
3
3
  */
4
- type ErrorEmitterAPI = {
4
+ type ErrorRaiseAPI = {
5
5
  /**
6
6
  * Builds and emit the contents of `ArgumentError`.
7
7
  *
@@ -2,33 +2,49 @@ type ErrorConstructorAPI = {
2
2
  /**
3
3
  * A customized and enhanced `TypeError`.
4
4
  */
5
- ArgumentError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").ArgumentError;
5
+ ArgumentError: {
6
+ new (meta: ArgumentErrorMeta): ArgumentErrorMeta;
7
+ };
6
8
  /**
7
9
  * A customized and enhanced `RangeError`.
8
10
  */
9
- IndexOutOfBoundsError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").IndexOutOfBoundsError;
11
+ IndexOutOfBoundsError: {
12
+ new (meta: IndexOutOfBoundsErrorMeta): IndexOutOfBoundsErrorMeta;
13
+ };
10
14
  /**
11
15
  * A customized error for invalid properties.
12
16
  */
13
- InvalidPropertyError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").InvalidPropertyError;
17
+ InvalidPropertyError: {
18
+ new (meta: InvalidPropertyErrorMeta): InvalidPropertyErrorMeta;
19
+ };
14
20
  /**
15
21
  * A customized error for missing parameter value.
16
22
  */
17
- MissingParameterError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").MissingParameterError;
23
+ MissingParameterError: {
24
+ new (meta: MissingParameterErrorMeta): MissingParameterErrorMeta;
25
+ };
18
26
  /**
19
27
  * A customized error for missing property.
20
28
  */
21
- MissingPropertyError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").MissingPropertyError;
29
+ MissingPropertyError: {
30
+ new (meta: MissingPropertyError): MissingPropertyError;
31
+ };
22
32
  /**
23
33
  * A customized error for unqualified element's tag.
24
34
  */
25
- NoSuchElementTagError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").NoSuchElementTagError;
35
+ NoSuchElementTagError: {
36
+ new (meta: NoSuchElementTagErrorMeta): NoSuchElementTagErrorMeta;
37
+ };
26
38
  /**
27
39
  * A customized error for not supported objects, etc.
28
40
  */
29
- NotSupportedError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").NotSupportedError;
41
+ NotSupportedError: {
42
+ new (meta: NotSupportedErrorMeta): NotSupportedErrorMeta;
43
+ };
30
44
  /**
31
45
  * A customized error for unknown property.
32
46
  */
33
- UnknownPropertyError: typeof import("../../../../utils/custom/error/constructor/error.custom.js").UnknownPropertyError;
47
+ UnknownPropertyError: {
48
+ new (meta: UnknownPropertyErrorMeta): UnknownPropertyErrorMeta;
49
+ };
34
50
  }
@@ -10,9 +10,9 @@ type BaseMeta<OtherArguments extends {} = {}> = {
10
10
 
11
11
  type ArgumentErrorMeta = BaseMeta<{ ReceivedArgument: string, ExpectedArguments: string[] }>;
12
12
  type IndexOutOfBoundsErrorMeta = BaseMeta<{ Index: number, MaxBound: number }>;
13
- type InvalidPropertyError = BaseMeta<{ PropertyId: string }>;
14
- type MissingParameterError = BaseMeta<{ Value: string }>;
15
- type MissingPropertyError = BaseMeta<{ PropertyId: string }>;
16
- type NoSuchElementTagError = BaseMeta<{ Tag: string, TagOf: "HTMLElement" | "MathMLElement" | "SVGElement" }>;
17
- type NotSupportedError = BaseMeta;
18
- type UnknownPropertyError = BaseMeta<{ PropertyId: string }>;
13
+ type InvalidPropertyErrorMeta = BaseMeta<{ PropertyId: string }>;
14
+ type MissingParameterErrorMeta = BaseMeta<{ Value: string }>;
15
+ type MissingPropertyErrorMeta = BaseMeta<{ PropertyId: string }>;
16
+ type NoSuchElementTagErrorMeta = BaseMeta<{ Tag: string, TagOf: "HTMLElement" | "MathMLElement" | "SVGElement" }>;
17
+ type NotSupportedErrorMeta = BaseMeta;
18
+ type UnknownPropertyErrorMeta = BaseMeta<{ PropertyId: string }>;
@@ -27,6 +27,31 @@ type CustomUtilitiesAPI = {
27
27
  */
28
28
  ConstructorOrTypeOf(arg: any): string | undefined;
29
29
 
30
+ /**
31
+ * Defines the given key-pair data to the target object.
32
+ *
33
+ * ***Options***:
34
+ * - `def` - Allows the defined key-pair data to be **writable**, **configurable**, and **enumerable**. (Default)
35
+ * - `hard` - Prevents the defined key-pair data to be **writable**, **configurable**, and **enumerable**.
36
+ * - `med` - Prevents the defined key-pair data to be **writable** and **configurable** but, can be **enumerable**.
37
+ * - `soft` - Prevents the defined key-pair data to be **writable** but, can be **configurable** and **enumerable**.
38
+ *
39
+ * @param obj - The target object to define the key-pair data at.
40
+ * @param key - The key of key-pair data.
41
+ * @param data - The data of key-pair data.
42
+ * @param opt - A options of what would be the state configuration of the defined key-pair data.
43
+ */
44
+ DefineProperty<K, D>(obj: { [prop: string]: any }, key: K, data: D, opt?: 'def' | 'hard' | 'med' | 'soft'): { [prop: string]: any } & { [prop in K]: D; };
45
+
46
+ /**
47
+ * Defines the given key-pair data to the `globalThis` or `window` API.
48
+ *
49
+ * @param key - The key of key-pair data.
50
+ * @param data - The data of key-pair data.
51
+ * @param opt - A options of what would be the state configuration of the defined key-pair data.
52
+ */
53
+ Global(key: string, data: any, opt?: 'def' | 'hard' | 'med' | 'soft'): void;
54
+
30
55
  /**
31
56
  * Retrieves the `name` property of the specified object.
32
57
  *
@@ -39,4 +64,62 @@ type CustomUtilitiesAPI = {
39
64
  * @returns The `name` property value of the object.
40
65
  */
41
66
  NameOf(obj: {}): string;
67
+
68
+ /**
69
+ * Validates and normalize the given numerical value to valid numerical value.
70
+ *
71
+ * @param num1 - The numerical value to normalize.
72
+ * @returns The normalized numerical value.
73
+ */
74
+ NormalizeNumbers(num1: number): number;
75
+
76
+ /**
77
+ * Validates and normalize the given collection of numerical values to a valid numerical values.
78
+ *
79
+ * @param num1 - The first numerical value to normalize.
80
+ * @param num2 - The second numerical value to normalize.
81
+ * @returns The normalized collection of numerical values.
82
+ */
83
+ NormalizeNumbers(num1: number, num2: number): number[];
84
+
85
+ /**
86
+ * Validates and normalize the given collection of numerical values to a valid numerical values.
87
+ *
88
+ * @param num1 - The first numerical value to normalize.
89
+ * @param num2 - The second numerical value to normalize.
90
+ * @param num3 - The third numerical value to normalize.
91
+ * @returns The normalized collection of numerical values.
92
+ */
93
+ NormalizeNumbers(num1: number, num2: number, num3: number): number[];
94
+
95
+ /**
96
+ * Validates and normalize the given collection of numerical values to a valid numerical values.
97
+ *
98
+ * @param num1 - The first numerical value to normalize.
99
+ * @param num2 - The second numerical value to normalize.
100
+ * @param num3 - The third numerical value to normalize.
101
+ * @param num4 - The fourth numerical value to normalize.
102
+ * @returns The normalized collection of numerical values.
103
+ */
104
+ NormalizeNumbers(num1: number, num2: number, num3: number, num4: number): number[];
105
+
106
+ /**
107
+ * Validates and normalize the given collection of numerical values to a valid numerical values.
108
+ *
109
+ * @param num1 - The first numerical value to normalize.
110
+ * @param num2 - The second numerical value to normalize.
111
+ * @param num3 - The third numerical value to normalize.
112
+ * @param num4 - The fourth numerical value to normalize.
113
+ * @param num5 - The fifth numerical value to normalize.
114
+ * @returns The normalized collection of numerical values.
115
+ */
116
+ NormalizeNumbers(num1: number, num2: number, num3: number, num4: number, num5: number): number[];
117
+
118
+ /**
119
+ * Validates and normalize the given collection of numerical values to a valid numerical values.
120
+ *
121
+ * @param nums - The collection of numerical values to normalize.
122
+ * @returns The normalized collection of numerical values.
123
+ */
124
+ NormalizeNumbers(...nums: number[]): number[];
42
125
  }
@@ -1,5 +1,6 @@
1
1
  /// <reference types="./api/api.d.ts" />
2
2
  /// <reference types="./api/element.d.ts" />
3
+ /// <reference types="./arithmetic/arithmetic.d.ts" />
3
4
  /// <reference types="./dom/dom.d.ts" />
4
5
  /// <reference types="./custom/custom.d.ts" />
5
6
  /// <reference types="./custom/error/error.d.ts" />
@@ -8,14 +9,15 @@
8
9
  /// <reference types="./storage/storage.d.ts" />
9
10
 
10
11
  declare global {
11
- readonly var Utils: EnhancedGlobalUtilsAPI;
12
- readonly var DOM: DomAPI;
12
+ readonly var Arithmetic: ArithmeticAPI;
13
13
  readonly var Custom: CustomAPI;
14
+ readonly var DOM: DomAPI;
14
15
  readonly var ERROR: ErrorAPI;
16
+ readonly var GetElementBy: DOMGetElementByAPI;
15
17
  readonly var Guards: GuardsAPI;
16
18
  readonly var Primitives: PrimitivesAPI;
17
19
  readonly var STORAGE: StorageAPI;
18
- readonly var GetElementBy: DOMGetElementByAPI;
20
+ readonly var Variables: VariablesAPI
19
21
  }
20
22
 
21
23
  export { };
@@ -0,0 +1,20 @@
1
+ import { DefineProperty, Global } from '../custom/utils/custom.utils.js';
2
+ import { IsNullOrUndefined } from '../guards/data-types/data-types.js';
3
+ import { HasProperty, IsStrEmpty } from '../guards/formats/formats.js';
4
+ import Divide from './operations/operation.divide.js';
5
+ import Multiply from './operations/operation.multiply.js';
6
+ import Subtract from './operations/operation.subtract.js';
7
+ import Sum from './operations/operation.sum.js';
8
+
9
+ function Arithmetics() {
10
+ const ArithmeticAPI = {};
11
+
12
+ for (const Method of [Divide, Multiply, Subtract, Sum]) {
13
+ const Key = Method.name;
14
+ if (!IsNullOrUndefined(Key) && !IsStrEmpty(Key) && !HasProperty(ArithmeticAPI, Key))
15
+ DefineProperty(ArithmeticAPI, Key, Method, "med");
16
+ }
17
+
18
+ Global("Arithmetic", ArithmeticAPI, "soft");
19
+ }
20
+ Arithmetics();
@@ -0,0 +1,78 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { NormalizeNumbers } from '../../custom/utils/custom.utils.js';
3
+ import { IsNum } from '../../guards/data-types/data-types.js';
4
+
5
+ /**
6
+ * Accumulates the total divided value of the given numerical values.
7
+ *
8
+ * @overload
9
+ * @param { number } num1 - The first and base numerical value of this operation.
10
+ * @param { number } num2 - The second numerical value to divide with the first numerical value.
11
+ * @returns { number } The total accumulated value of the given numerical values.
12
+ */
13
+ /**
14
+ * Accumulates the total divided value of the given numerical values.
15
+ *
16
+ * @overload
17
+ * @param { number } num1 - The first and base numerical value of this operation.
18
+ * @param { number } num2 - The second numerical value to divide with the first numerical value.
19
+ * @param { number } num3 - The third numerical value to divide with the first and second numerical value.
20
+ * @returns { number } The total accumulated value of the given numerical values.
21
+ */
22
+ /**
23
+ * Accumulates the total divided value of the given numerical values.
24
+ *
25
+ * @overload
26
+ * @param { number } num1 - The first and base numerical value of this operation.
27
+ * @param { number } num2 - The second numerical value to divide with the first numerical value.
28
+ * @param { number } num3 - The third numerical value to divide with the first and second numerical value.
29
+ * @param { number } num4 - The fourth numerical value to divide with the first, second, and third numerical value.
30
+ * @returns { number } The total accumulated value of the given numerical values.
31
+ */
32
+ /**
33
+ * Accumulates the total divided value of the given numerical values.
34
+ *
35
+ * @overload
36
+ * @param { number } num1 - The first and base numerical value of this operation.
37
+ * @param { number } num2 - The second numerical value to divide with the first numerical value.
38
+ * @param { number } num3 - The third numerical value to divide with the first and second numerical value.
39
+ * @param { number } num4 - The fourth numerical value to divide with the first, second, and third numerical value.
40
+ * @param { number } num5 - The fifth numerical value to divide with the first, second, third, and fourth numerical value.
41
+ * @returns { number } The total accumulated value of the given numerical values.
42
+ */
43
+ /**
44
+ * Accumulates the total divided value of the given numerical values.
45
+ *
46
+ * @overload
47
+ * @param { ...number } nums - The collection of numerical values to divide.
48
+ * @returns { number } The total accumulated value of the given numerical values.
49
+ */
50
+ export default function Divide(...nums) {
51
+ const Method = "Divide", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
52
+
53
+ if (ICtr < 2)
54
+ Raise._MissingParameterError(Method, P[ICtr], undefined);
55
+
56
+ const NUMS = NormalizeNumbers(...nums);
57
+ if (ICtr === 2) {
58
+ const [A, B] = NUMS;
59
+
60
+ return A === 0 || B === 0 ? NaN : A / B;
61
+ }
62
+
63
+ const BASE = NUMS[0];
64
+ if (BASE === 0)
65
+ return NaN;
66
+
67
+ let Accumulated = BASE;
68
+ for (const NUM of NUMS.slice(1)) {
69
+ if (NUM === 0) {
70
+ Accumulated = NaN;
71
+ break;
72
+ }
73
+
74
+ return Accumulated += NUM;
75
+ }
76
+
77
+ return Accumulated;
78
+ }
@@ -0,0 +1,75 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { NormalizeNumbers } from '../../custom/utils/custom.utils.js';
3
+ import { IsNum } from '../../guards/data-types/data-types.js';
4
+
5
+ /**
6
+ * Accumulates the total multiplied value of the given numerical values.
7
+ *
8
+ * @overload
9
+ * @param { number } num1 - The first and base numerical value of this operation.
10
+ * @param { number } num2 - The second numerical value to multiply with the first numerical value.
11
+ * @returns { number } The total accumulated value of the given numerical values.
12
+ */
13
+ /**
14
+ * Accumulates the total multiplied value of the given numerical values.
15
+ *
16
+ * @overload
17
+ * @param { number } num1 - The first and base numerical value of this operation.
18
+ * @param { number } num2 - The second numerical value to multiply with the first numerical value.
19
+ * @param { number } num3 - The third numerical value to multiply with the first and second numerical value.
20
+ * @returns { number } The total accumulated value of the given numerical values.
21
+ */
22
+ /**
23
+ * Accumulates the total multiplied value of the given numerical values.
24
+ *
25
+ * @overload
26
+ * @param { number } num1 - The first and base numerical value of this operation.
27
+ * @param { number } num2 - The second numerical value to multiply with the first numerical value.
28
+ * @param { number } num3 - The third numerical value to multiply with the first and second numerical value.
29
+ * @param { number } num4 - The fourth numerical value to multiply with the first, second, and third numerical value.
30
+ * @returns { number } The total accumulated value of the given numerical values.
31
+ */
32
+ /**
33
+ * Accumulates the total multiplied value of the given numerical values.
34
+ *
35
+ * @overload
36
+ * @param { number } num1 - The first and base numerical value of this operation.
37
+ * @param { number } num2 - The second numerical value to multiply with the first numerical value.
38
+ * @param { number } num3 - The third numerical value to multiply with the first and second numerical value.
39
+ * @param { number } num4 - The fourth numerical value to multiply with the first, second, and third numerical value.
40
+ * @param { number } num5 - The fifth numerical value to multiply with the first, second, third, and fourth numerical value.
41
+ * @returns { number } The total accumulated value of the given numerical values.
42
+ */
43
+ /**
44
+ * Accumulates the total multiplied value of the given numerical values.
45
+ *
46
+ * @overload
47
+ * @param { ...number } nums - The collection of numerical values to multiply.
48
+ * @returns { number } The total accumulated value of the given numerical values.
49
+ */
50
+ export default function Multiply(...nums) {
51
+ const Method = "Multiply", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
52
+
53
+ if (ICtr < 2)
54
+ Raise._MissingParameterError(Method, P[ICtr], undefined);
55
+
56
+ const NUMS = NormalizeNumbers(...nums);
57
+ if (ICtr === 2) {
58
+ const [A, B] = NUMS;
59
+
60
+ return A === 0 || B === 0 ? 0 : A * B;
61
+ }
62
+
63
+ const BASE = NUMS[0];
64
+ let Accumulated = BASE;
65
+ for (const NUM of NUMS.slice(1)) {
66
+ if (NUM === 0) {
67
+ Accumulated = 0;
68
+ break;
69
+ }
70
+
71
+ Accumulated *= NUM;
72
+ }
73
+
74
+ return Accumulated;
75
+ }