@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.
- package/README.MD +1 -1
- package/global.js +1 -1
- package/package.json +10 -2
- package/src/docs/api/api.md +3 -2
- package/src/docs/custom/custom.md +13 -33
- package/src/docs/custom/error/builder/builder.md +24 -0
- package/src/docs/custom/error/constructor/error.constructor.md +33 -0
- package/src/docs/custom/error/constructor/opts/argumentError.md +78 -0
- package/src/docs/custom/error/constructor/opts/indexOutOfBounds.md +77 -0
- package/src/docs/custom/error/constructor/opts/invalidPropertyError.md +83 -0
- package/src/docs/custom/error/constructor/opts/missingParameterError.md +75 -0
- package/src/docs/custom/error/constructor/opts/missingPropertyError.md +81 -0
- package/src/docs/custom/error/constructor/opts/noSuchElementTagError.md +81 -0
- package/src/docs/custom/error/constructor/opts/notSupportedError.md +81 -0
- package/src/docs/custom/error/constructor/opts/unknownPropertyError.md +82 -0
- package/src/docs/custom/error/error.md +36 -0
- package/src/docs/custom/utils/clamp.md +8 -6
- package/src/docs/custom/utils/constructorOrTypeOf.md +8 -6
- package/src/docs/custom/utils/generator/generator.md +8 -6
- package/src/docs/custom/utils/generator/methods/generator.newToken.md +11 -8
- package/src/docs/custom/utils/generator/methods/generator.randomCharacters.md +11 -8
- package/src/docs/custom/utils/generator/methods/generator.randomInteger.md +11 -8
- package/src/docs/custom/utils/nameOf.md +8 -6
- package/src/types/api/api.d.ts +27 -9
- package/src/types/arithmetic/arithmetic.d.ts +281 -0
- package/src/types/custom/error/builder/error.builder.d.ts +1 -1
- package/src/types/custom/error/constructor/error.custom.d.ts +24 -8
- package/src/types/custom/error/constructor/error.meta.d.ts +6 -6
- package/src/types/custom/utils/custom.utils.d.ts +83 -0
- package/src/types/global.d.ts +5 -3
- package/src/utils/arithmetic/arithmetic.js +20 -0
- package/src/utils/arithmetic/operations/operation.divide.js +78 -0
- package/src/utils/arithmetic/operations/operation.multiply.js +75 -0
- package/src/utils/arithmetic/operations/operation.subtract.js +64 -0
- package/src/utils/arithmetic/operations/operation.sum.js +65 -0
- package/src/utils/custom/error/builder/error.builder.js +3 -3
- package/src/utils/custom/error/error.js +2 -2
- package/src/utils/custom/utils/custom.utils.js +68 -4
- package/src/utils/custom/utils/generator/generator.js +4 -4
- package/src/utils/dom/attr/attr.class.js +4 -4
- package/src/utils/dom/attr/attr.id.js +3 -3
- package/src/utils/dom/attr/attr.style.js +5 -5
- package/src/utils/dom/element/create/element.create.js +14 -14
- package/src/utils/dom/element/getElementBy/dom.getElementBy.js +6 -6
- package/src/utils/dom/element/query/dom.query.js +3 -3
- package/src/utils/dom/element/tag-verifier/verifier.js +5 -5
- package/src/utils/dom/lifecycle/mount.js +3 -3
- package/src/utils/dom/lifecycle/unmount.js +2 -2
- package/src/utils/storage/local/storage.local.js +3 -3
- package/src/utils/storage/session/storage.session.js +3 -3
- package/src/utils/storage/storage.js +2 -2
- package/src/utils/variables.js +13 -7
|
@@ -0,0 +1,64 @@
|
|
|
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 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
|
+
const NUMS = NormalizeNumbers(...nums);
|
|
57
|
+
if (ICtr === 2) {
|
|
58
|
+
const [A, B] = NUMS;
|
|
59
|
+
|
|
60
|
+
return A - B;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return NUMS.reduce((acc, num) => acc -= num, 0);
|
|
64
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
import { MapOf } from '../../primitives/obj/obj.iterator.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Accumulates the total summation value of the given numerical values.
|
|
8
|
+
*
|
|
9
|
+
* @overload
|
|
10
|
+
* @param { number } num1 - The first and base numerical value of this operation.
|
|
11
|
+
* @param { number } num2 - The second numerical value to sum with the first numerical value.
|
|
12
|
+
* @returns { number } The total accumulated value of the given numerical values.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Accumulates the total summation value of the given numerical values.
|
|
16
|
+
*
|
|
17
|
+
* @overload
|
|
18
|
+
* @param { number } num1 - The first and base numerical value of this operation.
|
|
19
|
+
* @param { number } num2 - The second numerical value to sum with the first numerical value.
|
|
20
|
+
* @param { number } num3 - The third numerical value to sum with the first and second numerical value.
|
|
21
|
+
* @returns { number } The total accumulated value of the given numerical values.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Accumulates the total summation value of the given numerical values.
|
|
25
|
+
*
|
|
26
|
+
* @overload
|
|
27
|
+
* @param { number } num1 - The first and base numerical value of this operation.
|
|
28
|
+
* @param { number } num2 - The second numerical value to sum with the first numerical value.
|
|
29
|
+
* @param { number } num3 - The third numerical value to sum with the first and second numerical value.
|
|
30
|
+
* @param { number } num4 - The fourth numerical value to sum with the first, second, and third numerical value.
|
|
31
|
+
* @returns { number } The total accumulated value of the given numerical values.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Accumulates the total summation value of the given numerical values.
|
|
35
|
+
*
|
|
36
|
+
* @overload
|
|
37
|
+
* @param { number } num1 - The first and base numerical value of this operation.
|
|
38
|
+
* @param { number } num2 - The second numerical value to sum with the first numerical value.
|
|
39
|
+
* @param { number } num3 - The third numerical value to sum with the first and second numerical value.
|
|
40
|
+
* @param { number } num4 - The fourth numerical value to sum with the first, second, and third numerical value.
|
|
41
|
+
* @param { number } num5 - The fifth numerical value to sum with the first, second, third, and fourth numerical value.
|
|
42
|
+
* @returns { number } The total accumulated value of the given numerical values.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Accumulates the total summation value of the given numerical values.
|
|
46
|
+
*
|
|
47
|
+
* @overload
|
|
48
|
+
* @param { ...number } nums - The collection of numerical values to sum.
|
|
49
|
+
* @returns { number } The total accumulated value of the given numerical values.
|
|
50
|
+
*/
|
|
51
|
+
export default function Sum(...nums) {
|
|
52
|
+
const Method = "Sum", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
|
|
53
|
+
|
|
54
|
+
if (ICtr < 2)
|
|
55
|
+
Raise._MissingParameterError(Method, ICtr === 0 ? "num1" : "num2", undefined);
|
|
56
|
+
|
|
57
|
+
const NUMS = NormalizeNumbers(...nums);
|
|
58
|
+
if (ICtr === 2) {
|
|
59
|
+
const [A, B] = NUMS;
|
|
60
|
+
|
|
61
|
+
return A + B;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return NUMS.reduce((acc, num) => acc += num, 0);
|
|
65
|
+
}
|
|
@@ -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
|
|
42
|
+
const Raise = {
|
|
43
43
|
/**
|
|
44
44
|
* Name of this object.
|
|
45
45
|
*/
|
|
46
|
-
name: "
|
|
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
|
|
181
|
+
export default Raise;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as CustomErrorClasses from "./constructor/error.custom.js";
|
|
2
|
-
import
|
|
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,
|
|
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
|
-
import { IsNullOrUndefined, IsNum, IsPlainObj, IsStr } from '../../guards/data-types/data-types.js';
|
|
1
|
+
import { IsNullOrUndefined, IsNum, IsPlainObj, IsStr, IsArr } 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
|
|
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
|
-
|
|
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
|
-
|
|
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)`);
|
|
@@ -148,3 +148,67 @@ export function Global(key, data, opt = "def") {
|
|
|
148
148
|
|
|
149
149
|
DefineProperty(globalThis, key, data, opt);
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Validates the given collection of numerical values whether if its a valid numerical value, and returns
|
|
154
|
+
* the parsed numeric collection of it.
|
|
155
|
+
*
|
|
156
|
+
* ***Note***:
|
|
157
|
+
* - This automatically parse a argument data if its a numerical value in string format.
|
|
158
|
+
*
|
|
159
|
+
* @overload
|
|
160
|
+
* @param { number } num1 - The first numerical value to validate and normalize.
|
|
161
|
+
* @returns { number } The validate and parsed numerical value.
|
|
162
|
+
*
|
|
163
|
+
* @overload
|
|
164
|
+
* @param { number } num1 - The first numerical value to validate and normalize.
|
|
165
|
+
* @param { number } num2 - The second numerical value to validate and normalize.
|
|
166
|
+
* @returns { number[] } The validated and parsed collection of numerical values.
|
|
167
|
+
*
|
|
168
|
+
* @overload
|
|
169
|
+
* @param { number } num1 - The first numerical value to validate and normalize.
|
|
170
|
+
* @param { number } num2 - The second numerical value to validate and normalize.
|
|
171
|
+
* @param { number } num3 - The third numerical value to validate and normalize.
|
|
172
|
+
* @returns { number[] } The validated and parsed collection of numerical values.
|
|
173
|
+
*
|
|
174
|
+
* @overload
|
|
175
|
+
* @param { number } num1 - The first numerical value to validate and normalize.
|
|
176
|
+
* @param { number } num2 - The second numerical value to validate and normalize.
|
|
177
|
+
* @param { number } num3 - The third numerical value to validate and normalize.
|
|
178
|
+
* @param { number } num4 - The fourth numerical value to validate and normalize.
|
|
179
|
+
* @returns { number[] } The validated and parsed collection of numerical values.
|
|
180
|
+
*
|
|
181
|
+
* @overload
|
|
182
|
+
* @param { number } num1 - The first numerical value to validate and normalize.
|
|
183
|
+
* @param { number } num2 - The second numerical value to validate and normalize.
|
|
184
|
+
* @param { number } num3 - The third numerical value to validate and normalize.
|
|
185
|
+
* @param { number } num4 - The fourth numerical value to validate and normalize.
|
|
186
|
+
* @param { number } num5 - The fifth numerical value to validate and normalize.
|
|
187
|
+
* @returns { number[] } The validated and parsed collection of numerical values.
|
|
188
|
+
*
|
|
189
|
+
* @overload
|
|
190
|
+
* @param { ...number } nums - The given collection of numerical values to validate.
|
|
191
|
+
* @returns { number[] } The validated and parsed collection of numerical values.
|
|
192
|
+
*/
|
|
193
|
+
export function NormalizeNumbers(...nums) {
|
|
194
|
+
const Method = "NormalizeNumbers", ICtr = nums.length, P = ["num1", "num2", "num3", "num4", "num5"];
|
|
195
|
+
|
|
196
|
+
if (ICtr === 0)
|
|
197
|
+
Raise._MissingParameterError(Method, P[ICtr], undefined);
|
|
198
|
+
|
|
199
|
+
return nums.reduce((acc, num, pos) => {
|
|
200
|
+
const pN = parseInt(num, 10);
|
|
201
|
+
if (!IsNum(pN))
|
|
202
|
+
Raise._ArgumentError(Method, ICtr > 5 ? "nums" : P[pos], num, "Number");
|
|
203
|
+
|
|
204
|
+
if (ICtr > 1) {
|
|
205
|
+
if (!IsArr(acc))
|
|
206
|
+
acc = [];
|
|
207
|
+
|
|
208
|
+
acc.push(pN);
|
|
209
|
+
} else
|
|
210
|
+
acc = pN;
|
|
211
|
+
|
|
212
|
+
return acc;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
@@ -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
|
|
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
|
-
|
|
69
|
+
Raise._ArgumentError(this.constructor.name, "Size", Size, "Number");
|
|
70
70
|
|
|
71
71
|
if (!IsPlainObj(Conf))
|
|
72
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
19
|
+
Raise._ArgumentError(Method, "element", element, "Element");
|
|
20
20
|
|
|
21
21
|
if (!("classList" in element))
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
16
|
+
Raise._ArgumentError(Method, "element", element, "Element");
|
|
17
17
|
|
|
18
18
|
if (!("style" in element))
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsArrEmpty, IsPlainObjEmpty, IsStrEmpty } from '../../../guards/formats/formats.js';
|
|
3
3
|
import { IsArr, IsElement, IsNum, IsPlainObj, IsStr } from '../../../guards/data-types/data-types.js';
|
|
4
4
|
import { CountOf } from '../../../primitives/obj/obj.accessor.js';
|
|
@@ -20,10 +20,10 @@ function ValidateTagAndConfiguration(caller, tag, conf) {
|
|
|
20
20
|
const Caller = IsStr(caller) ? caller : "(Anonymous)";
|
|
21
21
|
|
|
22
22
|
if (!IsStr(tag))
|
|
23
|
-
|
|
23
|
+
Raise._ArgumentError(Caller, "tag", tag, "String");
|
|
24
24
|
|
|
25
25
|
if (!IsPlainObj(conf))
|
|
26
|
-
|
|
26
|
+
Raise._ArgumentError(Caller, "conf", conf, "Plain Object ({})");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -160,7 +160,7 @@ const Create = {
|
|
|
160
160
|
if (!IsNum(Conf.Tabindex)) {
|
|
161
161
|
const ParsedIndex = parseInt(Conf.TabIndex, 10);
|
|
162
162
|
if (!IsNum(ParsedIndex))
|
|
163
|
-
|
|
163
|
+
Raise._ArgumentError(Method, "conf.TabIndex", Conf.TabIndex, "Number");
|
|
164
164
|
|
|
165
165
|
Conf.TabIndex = ParsedIndex;
|
|
166
166
|
}
|
|
@@ -170,7 +170,7 @@ const Create = {
|
|
|
170
170
|
|
|
171
171
|
if (Conf.XML_Language) {
|
|
172
172
|
if (!IsStr(Conf.XML_Language))
|
|
173
|
-
|
|
173
|
+
Raise._ArgumentError(Method, "conf.XML_Language", Conf.XML_Language, "String");
|
|
174
174
|
|
|
175
175
|
if (!IsStrEmpty(Conf.XML_Language))
|
|
176
176
|
ThisElement.setAttribute("xml:lang", Conf.XML_Language);
|
|
@@ -178,7 +178,7 @@ const Create = {
|
|
|
178
178
|
|
|
179
179
|
if (Conf.XML_Space) {
|
|
180
180
|
if (!IsStr(Conf.XML_Space))
|
|
181
|
-
|
|
181
|
+
Raise._ArgumentError(Method, "conf.XML_Space", Conf.XML_Space, "String");
|
|
182
182
|
|
|
183
183
|
if (IsStrEmpty(Conf.XML_Space) || Conf.XML_Space !== "default" && Conf.XML_Space !== "preserve")
|
|
184
184
|
Conf.XML_Space = "default";
|
|
@@ -223,7 +223,7 @@ const Create = {
|
|
|
223
223
|
if (CountOf(Conf) > 0) {
|
|
224
224
|
if (Conf.Data) {
|
|
225
225
|
if (!IsPlainObj(Conf.Data))
|
|
226
|
-
|
|
226
|
+
Raise._ArgumentError(Method, "conf.Data", Conf.Data, "Plain Object ({})");
|
|
227
227
|
|
|
228
228
|
if (CountOf(Conf.Data) > 0)
|
|
229
229
|
for (const [DK, DV] of Object.entries(Conf.Data)) {
|
|
@@ -241,7 +241,7 @@ const Create = {
|
|
|
241
241
|
|
|
242
242
|
if (Conf.Dir) {
|
|
243
243
|
if (!IsStr(Conf.Dir))
|
|
244
|
-
|
|
244
|
+
Raise._ArgumentError(Method, "conf.Dir", Conf.Dir, "String");
|
|
245
245
|
|
|
246
246
|
if (IsStrEmpty(Conf.Dir) || (Conf.Dir !== "ltr" && Conf.Dir !== "rtl"))
|
|
247
247
|
Conf.Dir = "ltr";
|
|
@@ -254,7 +254,7 @@ const Create = {
|
|
|
254
254
|
|
|
255
255
|
if (Conf.Href) {
|
|
256
256
|
if (!IsStr(Conf.Href))
|
|
257
|
-
|
|
257
|
+
Raise._ArgumentError(Method, "conf.Href", Conf.Href, "String");
|
|
258
258
|
|
|
259
259
|
if (!IsStrEmpty(Conf.Href))
|
|
260
260
|
ThisElement.setAttribute("href", Conf.Href);
|
|
@@ -262,7 +262,7 @@ const Create = {
|
|
|
262
262
|
|
|
263
263
|
if (Conf.Id) {
|
|
264
264
|
if (!IsStr(Conf.Id))
|
|
265
|
-
|
|
265
|
+
Raise._ArgumentError(Method, "conf.Id", Conf.Id, "String");
|
|
266
266
|
|
|
267
267
|
if (!IsStrEmpty(Conf.Id))
|
|
268
268
|
ThisElement.id = Conf.Id;
|
|
@@ -270,7 +270,7 @@ const Create = {
|
|
|
270
270
|
|
|
271
271
|
if (Conf.ScriptLevel) {
|
|
272
272
|
if (!IsStr(Conf.ScriptLevel))
|
|
273
|
-
|
|
273
|
+
Raise._ArgumentError(Method, "conf.ScriptLevel", Conf.ScriptLevel, "String");
|
|
274
274
|
|
|
275
275
|
if (!IsStrEmpty(Conf.ScriptLevel))
|
|
276
276
|
ThisElement.setAttribute("scriptlevel", Conf.ScriptLevel);
|
|
@@ -278,7 +278,7 @@ const Create = {
|
|
|
278
278
|
|
|
279
279
|
if (Conf.MathBackground) {
|
|
280
280
|
if (!IsStr(Conf.MathBackground))
|
|
281
|
-
|
|
281
|
+
Raise._ArgumentError(Method, "conf.MathBackground", Conf.MathBackground, "String");
|
|
282
282
|
|
|
283
283
|
if (!IsStrEmpty(Conf.MathBackground))
|
|
284
284
|
ThisElement.setAttribute("mathbackground", Conf.MathBackground);
|
|
@@ -286,7 +286,7 @@ const Create = {
|
|
|
286
286
|
|
|
287
287
|
if (Conf.MathColor) {
|
|
288
288
|
if (!IsStr(Conf.MathColor))
|
|
289
|
-
|
|
289
|
+
Raise._ArgumentError(Method, "conf.MathColor", Conf.MathColor, "String");
|
|
290
290
|
|
|
291
291
|
if (!IsStrEmpty(Conf.MathColor))
|
|
292
292
|
ThisElement.setAttribute("mathcolor", Conf.MathColor);
|
|
@@ -294,7 +294,7 @@ const Create = {
|
|
|
294
294
|
|
|
295
295
|
if (Conf.MathSize) {
|
|
296
296
|
if (!IsStr(Conf.MathSize))
|
|
297
|
-
|
|
297
|
+
Raise._ArgumentError(Method, "conf.MathSize", Conf.MathSize, "String");
|
|
298
298
|
|
|
299
299
|
if (!IsStrEmpty(Conf.MathSize))
|
|
300
300
|
ThisElement.setAttribute("mathsize", Conf.MathSize);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsNullOrUndefined, IsParentNode, IsStr } from '../../../guards/data-types/data-types.js';
|
|
3
3
|
import { IsStrEmpty } from '../../../guards/formats/formats.js';
|
|
4
4
|
import { XMLNameSpace } from '../../../variables.js';
|
|
@@ -31,7 +31,7 @@ const GetElementBy = {
|
|
|
31
31
|
const Method = `${this.name}.ID`;
|
|
32
32
|
|
|
33
33
|
if (!IsStr(id))
|
|
34
|
-
|
|
34
|
+
Raise._ArgumentError(Method, "id", id, "String");
|
|
35
35
|
|
|
36
36
|
if (IsStrEmpty(id)) {
|
|
37
37
|
console.warn(`${Method}(@id: \'\'): Expects a non-empty-string! (Exited with null)`);
|
|
@@ -65,7 +65,7 @@ const GetElementBy = {
|
|
|
65
65
|
const Method = `${this.name}.ClassName`;
|
|
66
66
|
|
|
67
67
|
if (!IsStr(cls))
|
|
68
|
-
|
|
68
|
+
Raise._ArgumentError(Method, "cls", cls, "String");
|
|
69
69
|
|
|
70
70
|
if (IsStrEmpty(cls)) {
|
|
71
71
|
console.warn(`${Method}(@cls: \'\'): Expects a non-empty-string! (Exited with [])`);
|
|
@@ -101,7 +101,7 @@ const GetElementBy = {
|
|
|
101
101
|
const Method = `${this.name}.TagName`;
|
|
102
102
|
|
|
103
103
|
if (!IsStr(tag))
|
|
104
|
-
|
|
104
|
+
Raise._ArgumentError(Method, "tag", tag, "String");
|
|
105
105
|
|
|
106
106
|
if (IsStrEmpty(tag)) {
|
|
107
107
|
console.warn(`${Method}(@tag: \'\'): Expects a non-empty-string! (Exited with [])`);
|
|
@@ -141,10 +141,10 @@ const GetElementBy = {
|
|
|
141
141
|
const Method = `${this.name}.TagNameNS`;
|
|
142
142
|
|
|
143
143
|
if (!IsStr(namespace))
|
|
144
|
-
|
|
144
|
+
Raise._ArgumentError(Method, "namespace", namespace, "String");
|
|
145
145
|
|
|
146
146
|
if (!IsStr(tag))
|
|
147
|
-
|
|
147
|
+
Raise._ArgumentError(Method, "tag", tag, "String");
|
|
148
148
|
|
|
149
149
|
if (IsStrEmpty(namespace)) {
|
|
150
150
|
console.warn(`${Method}(@namespace: \'\'): Expects a non-empty-string! (Exited with [])`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsStr, IsParentNode } from '../../../guards/data-types/data-types.js';
|
|
3
3
|
import { IsStrEmpty } from '../../../guards/formats/formats.js';
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@ export function Select(selector, root = document) {
|
|
|
23
23
|
const Method = "Select";
|
|
24
24
|
|
|
25
25
|
if (!IsStr(selector))
|
|
26
|
-
|
|
26
|
+
Raise._ArgumentError(Method, "selector", selector, "String");
|
|
27
27
|
|
|
28
28
|
if (IsStrEmpty(selector)) {
|
|
29
29
|
console.warn(`${Method}(@selector: \'\'): Expects a non-empty-string! (Exited with null)`);
|
|
@@ -59,7 +59,7 @@ export function SelectAll(selector, root = document) {
|
|
|
59
59
|
const Method = "SelectAll";
|
|
60
60
|
|
|
61
61
|
if (!IsStr(selector))
|
|
62
|
-
|
|
62
|
+
Raise._ArgumentError(Method, "selector", selector, "String");
|
|
63
63
|
|
|
64
64
|
if (IsStrEmpty(selector)) {
|
|
65
65
|
console.warn(`${Method}(@selector: \'\'): Expects a non-empty-string! (Exited with null)`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsStrEmpty } from '../../../guards/formats/formats.js';
|
|
3
3
|
import { IsStr } from '../../../guards/data-types/data-types.js';
|
|
4
4
|
import * as VAR from '../../../variables.js';
|
|
@@ -14,7 +14,7 @@ export default function VerifyTag(tag) {
|
|
|
14
14
|
const Method = "VerifyTag";
|
|
15
15
|
|
|
16
16
|
if (!IsStr(tag) || IsStrEmpty(tag))
|
|
17
|
-
|
|
17
|
+
Raise._ArgumentError(Method, "tag", tag, "String");
|
|
18
18
|
|
|
19
19
|
tag = tag.trim().toLowerCase()
|
|
20
20
|
return {
|
|
@@ -26,7 +26,7 @@ export default function VerifyTag(tag) {
|
|
|
26
26
|
*/
|
|
27
27
|
HTMLElement() {
|
|
28
28
|
if (!VAR.HTMLElementTags.has(tag))
|
|
29
|
-
|
|
29
|
+
Raise._NoSuchElementTagError(`${Method}.HTMLElement`, "tag", tag, "HTMLElement");
|
|
30
30
|
|
|
31
31
|
return VAR.HTMLElementTags.get(tag)?.Generate() ?? null;
|
|
32
32
|
},
|
|
@@ -39,7 +39,7 @@ export default function VerifyTag(tag) {
|
|
|
39
39
|
*/
|
|
40
40
|
SVGElement() {
|
|
41
41
|
if (!VAR.SVGElementTags.has(tag))
|
|
42
|
-
|
|
42
|
+
Raise._NoSuchElementTagError(`${Method}.SVGElement`, "tag", tag, "SVGElement");
|
|
43
43
|
|
|
44
44
|
return VAR.SVGElementTags.get(tag)?.Generate() ?? null;
|
|
45
45
|
},
|
|
@@ -52,7 +52,7 @@ export default function VerifyTag(tag) {
|
|
|
52
52
|
*/
|
|
53
53
|
MathElement() {
|
|
54
54
|
if (!VAR.MathMLElementTags.has(tag))
|
|
55
|
-
|
|
55
|
+
Raise._NoSuchElementTagError(`${Method}.MathMLElement`, "tag", tag, "MathMLElement");
|
|
56
56
|
|
|
57
57
|
return VAR.MathMLElementTags.get(tag)?.Generate();
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsChildNode, IsParentNode, IsPropertyAt } from '../../guards/data-types/data-types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -27,7 +27,7 @@ export default function Mount(parentNode, ...childNodes) {
|
|
|
27
27
|
const Method = "Mount", PCN = childNodes.length > 1 ? "childNodes" : "childNode";
|
|
28
28
|
|
|
29
29
|
if (!IsParentNode(parentNode))
|
|
30
|
-
|
|
30
|
+
Raise._ArgumentError(Method, "parentNode", parentNode, "ParentNode");
|
|
31
31
|
|
|
32
32
|
if (childNodes.length === 0) {
|
|
33
33
|
console.warn(`${Method}(@childNode: NOT_PROVIDED): Expects at least 1 or more child node(s) to mount! (Exited)`);
|
|
@@ -41,7 +41,7 @@ export default function Mount(parentNode, ...childNodes) {
|
|
|
41
41
|
|
|
42
42
|
for (const Node of childNodes) {
|
|
43
43
|
if (!IsChildNode(Node))
|
|
44
|
-
|
|
44
|
+
Raise._ArgumentError(Method, PCN, Node, "ChildNode");
|
|
45
45
|
|
|
46
46
|
parentNode.appendChild(Node);
|
|
47
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Raise from '../../custom/error/builder/error.builder.js';
|
|
2
2
|
import { IsChildNode, IsPropertyAt } from '../../guards/data-types/data-types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -31,7 +31,7 @@ export default function Unmount(...childNodes) {
|
|
|
31
31
|
|
|
32
32
|
for (const Node of childNodes) {
|
|
33
33
|
if (!IsChildNode(Node))
|
|
34
|
-
|
|
34
|
+
Raise._ArgumentError(Method, PCN, Node, "ChildNode");
|
|
35
35
|
|
|
36
36
|
if (!IsPropertyAt(Node, "remove")) {
|
|
37
37
|
console.warn(`${Method}(@${PCN}${ICtr > 1 ? `[${Node}]` : `: ${Node}`}: NOT_SUPPORTED_METHOD): A given child node does not support the 'remove()' method! (${ICtr > 1 ? "Skipped" : "Exited"})`);
|