@carlsebastian/jsu 1.0.40 → 1.1.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.
Files changed (51) hide show
  1. package/README.MD +112 -0
  2. package/global.js +1 -0
  3. package/package.json +31 -3
  4. package/src/docs/api/api.md +22 -0
  5. package/src/docs/custom/custom.md +38 -0
  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 +45 -0
  18. package/src/docs/custom/utils/constructorOrTypeOf.md +39 -0
  19. package/src/docs/custom/utils/generator/generator.md +59 -0
  20. package/src/docs/custom/utils/generator/methods/generator.newToken.md +35 -0
  21. package/src/docs/custom/utils/generator/methods/generator.randomCharacters.md +35 -0
  22. package/src/docs/custom/utils/generator/methods/generator.randomInteger.md +41 -0
  23. package/src/docs/custom/utils/nameOf.md +39 -0
  24. package/src/types/api/api.d.ts +27 -9
  25. package/src/types/custom/error/builder/error.builder.d.ts +1 -1
  26. package/src/types/custom/error/constructor/error.custom.d.ts +24 -8
  27. package/src/types/custom/error/constructor/error.meta.d.ts +6 -6
  28. package/src/types/global.d.ts +3 -3
  29. package/src/utils/Arithmetic/arithmetic.js +0 -0
  30. package/src/utils/Arithmetic/operations/operation.divide.js +79 -0
  31. package/src/utils/Arithmetic/operations/operation.multiply.js +79 -0
  32. package/src/utils/Arithmetic/operations/operation.subtract.js +76 -0
  33. package/src/utils/Arithmetic/operations/operation.sum.js +76 -0
  34. package/src/utils/custom/error/builder/error.builder.js +3 -3
  35. package/src/utils/custom/error/error.js +2 -2
  36. package/src/utils/custom/utils/custom.utils.js +3 -3
  37. package/src/utils/custom/utils/generator/generator.js +4 -4
  38. package/src/utils/dom/attr/attr.class.js +4 -4
  39. package/src/utils/dom/attr/attr.id.js +3 -3
  40. package/src/utils/dom/attr/attr.style.js +5 -5
  41. package/src/utils/dom/element/create/element.create.js +14 -14
  42. package/src/utils/dom/element/getElementBy/dom.getElementBy.js +6 -6
  43. package/src/utils/dom/element/query/dom.query.js +3 -3
  44. package/src/utils/dom/element/tag-verifier/verifier.js +5 -5
  45. package/src/utils/dom/lifecycle/mount.js +3 -3
  46. package/src/utils/dom/lifecycle/unmount.js +2 -2
  47. package/src/utils/storage/local/storage.local.js +3 -3
  48. package/src/utils/storage/session/storage.session.js +3 -3
  49. package/src/utils/storage/storage.js +2 -2
  50. package/src/utils/variables.js +13 -7
  51. package/tsconfig.json +0 -14
@@ -112,7 +112,7 @@ interface DomAPI {
112
112
 
113
113
  interface ErrorAPI {
114
114
  Constructors: ErrorConstructorAPI;
115
- Emit: ErrorEmitterAPI;
115
+ Raise: ErrorRaiseAPI;
116
116
  }
117
117
 
118
118
  type GuardsAPI = GuardsDataTypesAPI & GuardsFormatAPI;
@@ -136,12 +136,30 @@ interface StorageAPI {
136
136
  SESSION: SessionStorageAPI;
137
137
  }
138
138
 
139
- interface EnhancedGlobalUtilsAPI {
140
- readonly Custom: CustomAPI;
141
- readonly DOM: DomAPI;
142
- readonly ERROR: ErrorAPI;
143
- readonly Guards: GuardsAPI;
144
- readonly Primitives: PrimitivesAPI;
145
- readonly STORAGE: StorageAPI;
146
- readonly GetElementBy: DOMGetElementByAPI;
139
+ interface VariablesAPI {
140
+ /**
141
+ * A collection of `HTMLElement` tags name.
142
+ *
143
+ * ***Source***: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements
144
+ */
145
+ HTMLElementTags: Map<keyof HTMLElementTags, { Generate(): HTMLElement; }>;
146
+
147
+ /**
148
+ * A collection of `SVGElement` tags name.
149
+ *
150
+ * ***Source***: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element
151
+ */
152
+ SVGElementTags: Map<keyof SVGElementTags, { Generate(): SVGElement; }>;
153
+
154
+ /**
155
+ * A collection of `MathMLElement` tags name.
156
+ *
157
+ * ***Source***: https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element
158
+ */
159
+ MathElementTags: Map<keyof MathElementTags, { Generate(): MathMLElement; }>;
160
+
161
+ /**
162
+ * A collection of available XML namespace of elements.
163
+ */
164
+ XMLNameSpace: ["http://www.w3.org/1998/Math/MathML", "http://www.w3.org/1999/xhtml", "http://www.w3.org/2000/svg"];
147
165
  }
@@ -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 }>;
@@ -8,14 +8,14 @@
8
8
  /// <reference types="./storage/storage.d.ts" />
9
9
 
10
10
  declare global {
11
- readonly var Utils: EnhancedGlobalUtilsAPI;
12
- readonly var DOM: DomAPI;
13
11
  readonly var Custom: CustomAPI;
12
+ readonly var DOM: DomAPI;
14
13
  readonly var ERROR: ErrorAPI;
14
+ readonly var GetElementBy: DOMGetElementByAPI;
15
15
  readonly var Guards: GuardsAPI;
16
16
  readonly var Primitives: PrimitivesAPI;
17
17
  readonly var STORAGE: StorageAPI;
18
- readonly var GetElementBy: DOMGetElementByAPI;
18
+ readonly var Variables: VariablesAPI
19
19
  }
20
20
 
21
21
  export { };
File without changes
@@ -0,0 +1,79 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { IsNum } from '../../guards/data-types/data-types.js';
3
+ import { MapOf } from '../../primitives/obj/obj.iterator.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
+ if (ICtr === 2) {
57
+ const [A, B] = MapOf(nums, (num, pos) =>
58
+ !IsNum(parseInt(num, 10)) ? Raise._ArgumentError(Method, P[pos], num, "Number")
59
+ : parseInt(num, 10)
60
+ );
61
+
62
+ return A === 0 ? NaN : A / B;
63
+ }
64
+
65
+ const Base = parseInt(nums[0], 10);
66
+ if (!IsNum(Base))
67
+ Raise._ArgumentError(Method, P[0], nums[0], "Number");
68
+
69
+ if (Base === 0)
70
+ return NaN;
71
+
72
+ return nums.slice(1).reduce((acc, num, pos) => {
73
+ const pN = parseInt(num, 10);
74
+ if (!IsNum(pN))
75
+ Raise._ArgumentError(Method, ICtr > 5 ? "nums" : P[pos + 1], num, "Number");
76
+
77
+ return acc /= pN;
78
+ }, Base);
79
+ }
@@ -0,0 +1,79 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { IsNum } from '../../guards/data-types/data-types.js';
3
+ import { MapOf } from '../../primitives/obj/obj.iterator.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
+ if (ICtr === 2) {
57
+ const [A, B] = MapOf(nums, (num, pos) =>
58
+ !IsNum(parseInt(num, 10)) ? Raise._ArgumentError(Method, P[pos], num, "Number")
59
+ : parseInt(num, 10)
60
+ );
61
+
62
+ return A === 0 ? A : A + B;
63
+ }
64
+
65
+ const Base = parseInt(nums[0], 10);
66
+ if (!IsNum(Base))
67
+ Raise._ArgumentError(Method, P[0], nums[0], "Number");
68
+
69
+ if (Base === 0)
70
+ return 0;
71
+
72
+ return nums.slice(1).reduce((acc, num, pos) => {
73
+ const pN = parseInt(num, 10);
74
+ if (!IsNum(pN))
75
+ Raise._ArgumentError(Method, ICtr > 5 ? "nums" : P[pos + 1], num, "Number");
76
+
77
+ return acc += pN;
78
+ }, Base);
79
+ }
@@ -0,0 +1,76 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { IsNum } from '../../guards/data-types/data-types.js';
3
+ import { MapOf } from '../../primitives/obj/obj.iterator.js';
4
+
5
+ /**
6
+ * Accumulates the total subtracted 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 subtract with the first numerical value.
11
+ * @returns { number } The total accumulated value of the given numerical values.
12
+ */
13
+ /**
14
+ * Accumulates the total subtracted 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 subtract with the first numerical value.
19
+ * @param { number } num3 - The third numerical value to subtract 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 subtracted 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 subtract with the first numerical value.
28
+ * @param { number } num3 - The third numerical value to subtract with the first and second numerical value.
29
+ * @param { number } num4 - The fourth numerical value to subtract 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 subtracted 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 subtract with the first numerical value.
38
+ * @param { number } num3 - The third numerical value to subtract with the first and second numerical value.
39
+ * @param { number } num4 - The fourth numerical value to subtract with the first, second, and third numerical value.
40
+ * @param { number } num5 - The fifth numerical value to subtract 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 subtracted value of the given numerical values.
45
+ *
46
+ * @overload
47
+ * @param { ...number } nums - The collection of numerical values to subtract.
48
+ * @returns { number } The total accumulated value of the given numerical values.
49
+ */
50
+ export default function Subtract(...nums) {
51
+ const Method = "Subtract", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
52
+
53
+ if (ICtr < 2)
54
+ Raise._MissingParameterError(Method, P[ICtr], undefined);
55
+
56
+ if (ICtr === 2) {
57
+ const [A, B] = MapOf(nums, (num, pos) =>
58
+ !IsNum(parseInt(num, 10)) ? Raise._ArgumentError(Method, P[pos], num, "Number")
59
+ : parseInt(num, 10)
60
+ );
61
+
62
+ return A + B;
63
+ }
64
+
65
+ const Base = parseInt(nums[0], 10);
66
+ if (!IsNum(Base))
67
+ Raise._ArgumentError(Method, P[0], nums[0], "Number");
68
+
69
+ return nums.slice(1).reduce((acc, num, pos) => {
70
+ const pN = parseInt(num, 10);
71
+ if (!IsNum(pN))
72
+ Raise._ArgumentError(Method, ICtr > 5 ? "nums" : P[pos + 1], num, "Number");
73
+
74
+ return acc += pN;
75
+ }, Base);
76
+ }
@@ -0,0 +1,76 @@
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
+ import { IsNum } from '../../guards/data-types/data-types.js';
3
+ import { MapOf } from '../../primitives/obj/obj.iterator.js';
4
+
5
+ /**
6
+ * Accumulates the total summation 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 sum with the first numerical value.
11
+ * @returns { number } The total accumulated value of the given numerical values.
12
+ */
13
+ /**
14
+ * Accumulates the total summation 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 sum with the first numerical value.
19
+ * @param { number } num3 - The third numerical value to sum 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 summation 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 sum with the first numerical value.
28
+ * @param { number } num3 - The third numerical value to sum with the first and second numerical value.
29
+ * @param { number } num4 - The fourth numerical value to sum 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 summation 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 sum with the first numerical value.
38
+ * @param { number } num3 - The third numerical value to sum with the first and second numerical value.
39
+ * @param { number } num4 - The fourth numerical value to sum with the first, second, and third numerical value.
40
+ * @param { number } num5 - The fifth numerical value to sum 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 summation value of the given numerical values.
45
+ *
46
+ * @overload
47
+ * @param { ...number } nums - The collection of numerical values to sum.
48
+ * @returns { number } The total accumulated value of the given numerical values.
49
+ */
50
+ export default function Sum(...nums) {
51
+ const Method = "Sum", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
52
+
53
+ if (ICtr < 2)
54
+ Raise._MissingParameterError(Method, ICtr === 0 ? "num1" : "num2", undefined);
55
+
56
+ if (ICtr === 2) {
57
+ let [n1, n2] = MapOf(nums, (num, pos) =>
58
+ !IsNum(parseInt(num)) ? Raise._ArgumentError(Method, P[pos], num, "Number")
59
+ : parseInt(num, 10)
60
+ );
61
+
62
+ return n1 + n2;
63
+ }
64
+
65
+ const Base = parseInt(nums[0], 10);
66
+ if (!IsNum(Base))
67
+ Raise._ArgumentError(Method, P[0], nums[0], "Number");
68
+
69
+ return nums.slice(1).reduce((acc, num, pos) => {
70
+ const pN = parseInt(num, 10);
71
+ if (!IsNum(pN))
72
+ Raise._ArgumentError(Method, ICtr > 5 ? "nums" : P[pos + 1], num, "Number");
73
+
74
+ return acc += pN;
75
+ }, Base);
76
+ }
@@ -39,11 +39,11 @@ const BuildMeta = (message, c_message, emitter_id, argument_id, otherArgument, g
39
39
  * - The contents of available error builder(s) in this object are fixed, only the specified or
40
40
  * required value are changing.
41
41
  */
42
- const Emit = {
42
+ const Raise = {
43
43
  /**
44
44
  * Name of this object.
45
45
  */
46
- name: "Emit",
46
+ name: "Raise",
47
47
 
48
48
  /**
49
49
  * Builds and emit the contents of `@ArgumentError`.
@@ -178,4 +178,4 @@ const Emit = {
178
178
  }
179
179
  }
180
180
 
181
- export default Emit;
181
+ export default Raise;
@@ -1,5 +1,5 @@
1
1
  import * as CustomErrorClasses from "./constructor/error.custom.js";
2
- import Emit from './builder/error.builder.js';
2
+ import Raise from './builder/error.builder.js';
3
3
  import { DefineProperty, Global, NameOf } from '../utils/custom.utils.js';
4
4
  import { IsNullOrUndefined, IsPropertyAt, IsStr } from '../../guards/data-types/data-types.js';
5
5
  import { IsStrEmpty } from '../../guards/formats/formats.js';
@@ -11,7 +11,7 @@ function ERROR() {
11
11
  const ErrorAPI = {};
12
12
  const Constructors = { name: "Constructors", ...CustomErrorClasses };
13
13
 
14
- for (const Method of [Constructors, Emit]) {
14
+ for (const Method of [Constructors, Raise]) {
15
15
  const Key = NameOf(Method);
16
16
  if (!IsNullOrUndefined(Key) && !IsStrEmpty(Key) && !IsPropertyAt(ErrorAPI, Key) && !(Key === "(ANONYMOUS)"))
17
17
  DefineProperty(ErrorAPI, NameOf(Method), Method, "med")
@@ -1,7 +1,7 @@
1
1
  import { IsNullOrUndefined, IsNum, IsPlainObj, IsStr } from '../../guards/data-types/data-types.js';
2
2
  import { IsStrEmpty } from '../../guards/formats/formats.js';
3
3
  import { EachOf, MapOf, SomeOf } from '../../primitives/obj/obj.iterator.js';
4
- import Emit from '../error/builder/error.builder.js';
4
+ import Raise from '../error/builder/error.builder.js';
5
5
 
6
6
  /**
7
7
  * Retrieves the `name` property of the specified `function` or other `object` that supports this property.
@@ -92,7 +92,7 @@ export function DefineProperty(obj = {}, key, data, opt = "def") {
92
92
  obj = {};
93
93
 
94
94
  if (!IsStr(key))
95
- Emit._ArgumentError(Method, "key", key, "String");
95
+ Raise._ArgumentError(Method, "key", key, "String");
96
96
 
97
97
  if (IsStrEmpty(key)) {
98
98
  console.warn(`${Method}(@key: \'\'): Expects a not-empty-string! (Exited)`);
@@ -136,7 +136,7 @@ export function Global(key, data, opt = "def") {
136
136
  const Method = "Global";
137
137
 
138
138
  if (!IsStr(key))
139
- Emit._ArgumentError(Method, "key", key, "String");
139
+ Raise._ArgumentError(Method, "key", key, "String");
140
140
 
141
141
  if (IsStrEmpty(key)) {
142
142
  console.warn(`${Method}(@key: \'\'): Expects a non-empty-string! (Exited)`);
@@ -3,7 +3,7 @@ import { IsBool, IsNum, IsPlainObj } from '../../../guards/data-types/data-types
3
3
  import { CountOf, KeysOf } from '../../../primitives/obj/obj.accessor.js';
4
4
  import { EachOf, MapOf } from '../../../primitives/obj/obj.iterator.js';
5
5
  import Str from '../../../primitives/str/str.js';
6
- import Emit from '../../error/builder/error.builder.js';
6
+ import Raise from '../../error/builder/error.builder.js';
7
7
  import { Clamp } from '../custom.utils.js';
8
8
 
9
9
  /**
@@ -66,10 +66,10 @@ export default class Generator {
66
66
  const CONFKeys = ["numbers", "symbols", "lowercase", "uppercase", "secure"];
67
67
 
68
68
  if (!IsNum(Size))
69
- Emit._ArgumentError(this.constructor.name, "Size", Size, "Number");
69
+ Raise._ArgumentError(this.constructor.name, "Size", Size, "Number");
70
70
 
71
71
  if (!IsPlainObj(Conf))
72
- Emit._ArgumentError(this.constructor.name, "Conf", Conf, "Plain Object");
72
+ Raise._ArgumentError(this.constructor.name, "Conf", Conf, "Plain Object");
73
73
 
74
74
  if (IsPlainObjEmpty(Conf))
75
75
  Conf = { numbers: true, symbols: true, lowercase: true, uppercase: true, secure: false };
@@ -130,7 +130,7 @@ export default class Generator {
130
130
 
131
131
  EachOf(Range, (R, Pos) => {
132
132
  if (!IsNum(R))
133
- Emit._ArgumentError(Method, ["min", "max"][Pos], R, "Number");
133
+ Raise._ArgumentError(Method, ["min", "max"][Pos], R, "Number");
134
134
  });
135
135
 
136
136
  if (Range[0] > Range[1])
@@ -1,4 +1,4 @@
1
- import Emit from '../../custom/error/builder/error.builder.js';
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
2
  import { IsStrEmpty } from '../../guards/formats/formats.js';
3
3
  import { IsArr, IsElement, IsStr } from '../../guards/data-types/data-types.js';
4
4
  import { CountOf } from '../../primitives/obj/obj.accessor.js';
@@ -16,10 +16,10 @@ export default function ClassOf(element) {
16
16
  const Method = "ClassOf";
17
17
 
18
18
  if (!IsElement(element))
19
- Emit._ArgumentError(Method, "element", element, "Element");
19
+ Raise._ArgumentError(Method, "element", element, "Element");
20
20
 
21
21
  if (!("classList" in element))
22
- Emit._NotSupportedError(Method, "classList");
22
+ Raise._NotSupportedError(Method, "classList");
23
23
 
24
24
  const ClassList = element.classList;
25
25
  return {
@@ -165,7 +165,7 @@ export default function ClassOf(element) {
165
165
  return false;
166
166
 
167
167
  if (forceState && typeof forceState !== "boolean")
168
- Emit._ArgumentError(Caller, "forceState", forceState, "Boolean");
168
+ Raise._ArgumentError(Caller, "forceState", forceState, "Boolean");
169
169
 
170
170
  const Response = [];
171
171
  for (const token of tokens) {
@@ -1,4 +1,4 @@
1
- import Emit from '../../custom/error/builder/error.builder.js';
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
2
  import { IsStrEmpty } from '../../guards/formats/formats.js';
3
3
  import { IsElement, IsNullOrUndefined, IsStr } from '../../guards/data-types/data-types.js';
4
4
 
@@ -12,7 +12,7 @@ export default function IdOf(element) {
12
12
  const Method = "IdOf";
13
13
 
14
14
  if (!IsElement(element))
15
- Emit._ArgumentError(Method, "element", element, "Element");
15
+ Raise._ArgumentError(Method, "element", element, "Element");
16
16
 
17
17
  return {
18
18
  /**
@@ -49,7 +49,7 @@ export default function IdOf(element) {
49
49
  const Caller = `${Method}.Set`;
50
50
 
51
51
  if (!IsStr(id))
52
- Emit._ArgumentError(Caller, "id", id, "String");
52
+ Raise._ArgumentError(Caller, "id", id, "String");
53
53
 
54
54
  if (IsStrEmpty(id)) {
55
55
  element.removeAttribute("id");
@@ -1,4 +1,4 @@
1
- import Emit from '../../custom/error/builder/error.builder.js';
1
+ import Raise from '../../custom/error/builder/error.builder.js';
2
2
  import { IsPlainObjEmpty, IsStrEmpty } from '../../guards/formats/formats.js';
3
3
  import { IsArr, IsElement, IsPlainObj, IsStr } from '../../guards/data-types/data-types.js';
4
4
  import { CountOf } from '../../primitives/obj/obj.accessor.js';
@@ -13,10 +13,10 @@ export default function StyleOf(element) {
13
13
  const Method = "StyleOf";
14
14
 
15
15
  if (!IsElement(element))
16
- Emit._ArgumentError(Method, "element", element, "Element");
16
+ Raise._ArgumentError(Method, "element", element, "Element");
17
17
 
18
18
  if (!("style" in element))
19
- Emit._NotSupportedError(Method, "style");
19
+ Raise._NotSupportedError(Method, "style");
20
20
 
21
21
  /** @type { CSSStyleDeclaration } */
22
22
  const StyleObj = element.style;
@@ -31,7 +31,7 @@ export default function StyleOf(element) {
31
31
  const Caller = `${Method}.Set`;
32
32
 
33
33
  if (!IsPlainObj(CSSObj))
34
- Emit._ArgumentError(Caller, "CSSObj", CSSObj, "Plain Object ({})");
34
+ Raise._ArgumentError(Caller, "CSSObj", CSSObj, "Plain Object ({})");
35
35
 
36
36
  if (IsPlainObjEmpty(CSSObj))
37
37
  return;
@@ -108,7 +108,7 @@ export default function StyleOf(element) {
108
108
  Get(CSSProperty) {
109
109
  const Caller = `${Method}.Get`;
110
110
  if (!IsStr(CSSProperty))
111
- Emit._ArgumentError(Caller, "CSSProperty", CSSProperty, "String");
111
+ Raise._ArgumentError(Caller, "CSSProperty", CSSProperty, "String");
112
112
 
113
113
  if (IsStrEmpty(CSSProperty)) {
114
114
  console.warn(`${Caller}(@CSSProperty: ${CSSProperty}): Expects a non-empty string key value! (Exited with null)`);