@carlsebastian/jsu 1.0.34

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 (59) hide show
  1. package/LICENSE +201 -0
  2. package/package.json +58 -0
  3. package/src/global.js +7 -0
  4. package/src/types/api/api.d.ts +147 -0
  5. package/src/types/api/element.d.ts +55 -0
  6. package/src/types/custom/custom.d.ts +8 -0
  7. package/src/types/custom/error/builder/error.builder.d.ts +78 -0
  8. package/src/types/custom/error/constructor/error.base.d.ts +4 -0
  9. package/src/types/custom/error/constructor/error.custom.d.ts +34 -0
  10. package/src/types/custom/error/constructor/error.meta.d.ts +18 -0
  11. package/src/types/custom/error/error.d.ts +5 -0
  12. package/src/types/custom/utils/custom.utils.d.ts +42 -0
  13. package/src/types/custom/utils/generator/generator.d.ts +92 -0
  14. package/src/types/dom/attr/attr.class.d.ts +81 -0
  15. package/src/types/dom/attr/attr.id.d.ts +23 -0
  16. package/src/types/dom/attr/attr.style.d.ts +32 -0
  17. package/src/types/dom/dom.d.ts +8 -0
  18. package/src/types/dom/element/create/element.create.d.ts +67 -0
  19. package/src/types/dom/element/getElementBy/dom.getElementBy.d.ts +71 -0
  20. package/src/types/dom/element/tag-verifier/verifier.d.ts +16 -0
  21. package/src/types/global.d.ts +13 -0
  22. package/src/types/guards/data-types/data-types.d.ts +5 -0
  23. package/src/types/guards/formats/formats.d.ts +5 -0
  24. package/src/types/guards/guards.d.ts +8 -0
  25. package/src/types/primitives/obj/obj.accessor.d.ts +5 -0
  26. package/src/types/primitives/obj/obj.iterator.d.ts +5 -0
  27. package/src/types/primitives/primitives.d.ts +8 -0
  28. package/src/types/primitives/str/str.d.ts +26 -0
  29. package/src/types/storage/local/storage.local.d.ts +86 -0
  30. package/src/types/storage/session/storage.session.d.ts +86 -0
  31. package/src/types/storage/storage.d.ts +8 -0
  32. package/src/utils/custom/custom.js +20 -0
  33. package/src/utils/custom/error/builder/error.builder.js +181 -0
  34. package/src/utils/custom/error/constructor/error.base.js +71 -0
  35. package/src/utils/custom/error/constructor/error.custom.js +107 -0
  36. package/src/utils/custom/error/error.js +23 -0
  37. package/src/utils/custom/utils/custom.utils.js +150 -0
  38. package/src/utils/custom/utils/generator/generator.js +222 -0
  39. package/src/utils/dom/attr/attr.class.js +186 -0
  40. package/src/utils/dom/attr/attr.id.js +64 -0
  41. package/src/utils/dom/attr/attr.style.js +128 -0
  42. package/src/utils/dom/dom.js +29 -0
  43. package/src/utils/dom/element/create/element.create.js +312 -0
  44. package/src/utils/dom/element/getElementBy/dom.getElementBy.js +171 -0
  45. package/src/utils/dom/element/query/dom.query.js +75 -0
  46. package/src/utils/dom/element/tag-verifier/verifier.js +60 -0
  47. package/src/utils/dom/lifecycle/mount.js +48 -0
  48. package/src/utils/dom/lifecycle/unmount.js +43 -0
  49. package/src/utils/guards/data-types/data-types.js +201 -0
  50. package/src/utils/guards/formats/formats.js +274 -0
  51. package/src/utils/guards/guards.js +21 -0
  52. package/src/utils/primitives/obj/obj.accessor.js +242 -0
  53. package/src/utils/primitives/obj/obj.iterator.js +148 -0
  54. package/src/utils/primitives/primitives.js +23 -0
  55. package/src/utils/primitives/str/str.js +52 -0
  56. package/src/utils/storage/local/storage.local.js +236 -0
  57. package/src/utils/storage/session/storage.session.js +236 -0
  58. package/src/utils/storage/storage.js +59 -0
  59. package/src/utils/variables.js +78 -0
@@ -0,0 +1,242 @@
1
+ import Emit from '../../custom/error/builder/error.builder.js';
2
+ import { ConstructorOrTypeOf } from '../../custom/utils/custom.utils.js';
3
+ import { IsArrEmpty, IsMapObjEmpty, IsPlainObjEmpty, IsSetObjEmpty, IsStrEmpty } from "../../guards/formats/formats.js";
4
+ import { IsArr, IsMapObj, IsNullOrUndefined, IsNum, IsPlainObj, IsSetObj, IsStr } from "../../guards/data-types/data-types.js";
5
+
6
+ /**
7
+ * Returns an iterable entries of data from the specified ***object*** or
8
+ * an array of data from a ***plain object***.
9
+ *
10
+ * ***Expected Objects***:
11
+ * - ***ARRAY*** | ***PLAIN OBJECT*** | ***MAP OBJECT*** | ***SET OBJECT***.
12
+ *
13
+ * ***Notes***:
14
+ * - When object is ***plain object*** it would preserve the array (same result as Object.entries(o)),
15
+ * the same thing with objects that is an Array, Map, and Set. (E.g. ArrayIterator, MapIterator, and SetIterator)
16
+ *
17
+ * @template T
18
+ * @param { T } obj - The object to get its content's entries.
19
+ * @returns { T extends Map<infer K, infer V> ? MapIterator<[K, V]> :
20
+ * T extends Set<infer U> ? SetIterator<[U, U]> :
21
+ * T extends readonly Array<infer V> ? ArrayIterator<[number, V]>
22
+ * T extends { [p: string]: infer V } | ArrayLike<infer V> ? Array<[string, V]> :
23
+ * never[]
24
+ * }
25
+ */
26
+ export function EntriesOf(obj) {
27
+ // ❌ - Exits when @obj is none of these expected object formats.
28
+ if (!IsArr(obj) && !IsPlainObj(obj) && !IsMapObj(obj) && !IsSetObj(obj))
29
+ Emit._ArgumentError("EntriesOf", "obj", ConstructorOrTypeOf(obj), "Array", "Map", "Plain Object", "Set");
30
+
31
+ // ⚠️ - Warns when the specified @obj is empty or does not have present contents.
32
+ if (IsPlainObj(obj) && IsPlainObjEmpty(obj) || IsArr(obj) && IsArrEmpty(obj) ||
33
+ IsMapObj(obj) && IsMapObjEmpty(obj) || IsSetObj(obj) && IsSetObjEmpty(obj)
34
+ ) {
35
+ console.warn(`EntriesOf(@obj: NO_ELEMENTS_FOUND): The specified object does not have any present elements or contents! (Exited with [])`);
36
+ return [];
37
+ }
38
+
39
+ // 📍 - @type = OBJECT
40
+ if (IsPlainObj(obj))
41
+ return Object.entries(obj);
42
+
43
+ // 📍 - @type = ARRAY | MAP | SET
44
+ if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
45
+ return obj.entries();
46
+
47
+ // 📍 - @type = undefined | null.
48
+ // 💬 - Default detection if type is not in the option (for module namespace, freezed objects, and no constructor objects)
49
+ if (IsNullOrUndefined(ConstructorOrTypeOf(obj)) || IsNullOrUndefined(Object.getPrototypeOf(obj)))
50
+ if (IsPlainObj(obj))
51
+ return Object.entries(obj);
52
+ else if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
53
+ return obj.entries();
54
+ else
55
+ return [];
56
+ }
57
+
58
+ /**
59
+ * Returns an iterable keys or index of the specified ***object***.
60
+ *
61
+ * ***Expected Objects***:
62
+ * - ***ARRAY*** | ***PLAIN OBJECT*** | ***MAP OBJECT*** | ***SET OBJECT***.
63
+ *
64
+ * @template T
65
+ * @param { T } obj - The object to get its content's keys.
66
+ * @returns { T extends Map<infer K, unknown> ? MapIterator<K> :
67
+ * T extends Set<infer U> ? SetIterator<U> :
68
+ * T extends Array<infer V> ? ArrayIterator<number> :
69
+ * T extends { [p: string]: infer V } | ArrayLike<infer V> ? Array<string> :
70
+ * never[]
71
+ * }
72
+ */
73
+ export function KeysOf(obj) {
74
+ // ❌ - Exits when @obj is none of these expected object formats.
75
+ if (!IsArr(obj) && !IsPlainObj(obj) && !IsMapObj(obj) && !IsSetObj(obj))
76
+ Emit._ArgumentError("KeysOf", "obj", ConstructorOrTypeOf(obj), "Array", "Map", "Plain Object", "Set");
77
+
78
+ // ⚠️ - Warns when the specified @obj is empty or does not have present contents.
79
+ if (IsPlainObj(obj) && IsPlainObjEmpty(obj) || IsArr(obj) && IsArrEmpty(obj) ||
80
+ IsMapObj(obj) && IsMapObjEmpty(obj) || IsSetObj(obj) && IsSetObjEmpty(obj)
81
+ ) {
82
+ console.warn(`KeysOf(@obj: NO_ELEMENTS_FOUND): The specified object does not have any present elements or contents! (Exited with [])`);
83
+ return [];
84
+ }
85
+
86
+ // 📍 - @type = OBJECT
87
+ if (IsPlainObj(obj))
88
+ return Object.keys(obj);
89
+
90
+ // 📍 - @type = ARRAY | MAP | SET
91
+ if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
92
+ return obj.keys();
93
+
94
+ // 📍 - @type = undefined | null.
95
+ // 💬 - Default detection if type is not in the option (for module namespace, freezed objects, and no constructor objects)
96
+ if (IsNullOrUndefined(obj.constructor) || IsNullOrUndefined(Object.getPrototypeOf(obj)))
97
+ if (IsPlainObj(obj))
98
+ return Object.keys(obj);
99
+ else if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
100
+ return obj.keys();
101
+ else
102
+ return [];
103
+ }
104
+
105
+ /**
106
+ * Returns an iterable values of the specified ***object***.
107
+ *
108
+ * ***Expected Objects***:
109
+ * - ***ARRAY*** | ***PLAIN OBJECT*** | ***MAP OBJECT*** | ***SET OBJECT***.
110
+ *
111
+ * @template T
112
+ * @param { T } obj - The object to return its content's values.
113
+ * @throws `@ArgumentError` when the specified object is invalid.
114
+ * @returns { T extends Map<unknown, infer V> ? MapIterator<V> :
115
+ * T extends Set<infer U> ? SetIterator<U> :
116
+ * T extends Array<infer V> ? ArrayIterator<V> :
117
+ * T extends { [p: string]: infer V } | ArrayLike<infer V> ? Array<V> :
118
+ * never[]
119
+ * }
120
+ */
121
+ export function ValuesOf(obj) {
122
+ // ❌ - Exits when @obj is none of these expected object formats.
123
+ if (!IsArr(obj) && !IsPlainObj(obj) && !IsMapObj(obj) && !IsSetObj(obj))
124
+ Emit._ArgumentError("ValuesOf", "obj", ConstructorOrTypeOf(obj), "Array", "Map", "Plain Object", "Set");
125
+
126
+ // ⚠️ - Warns when the specified @obj is empty or does not have present contents.
127
+ if (IsPlainObj(obj) && IsPlainObjEmpty(obj) || IsArr(obj) && IsArrEmpty(obj) ||
128
+ IsMapObj(obj) && IsMapObjEmpty(obj) || IsSetObj(obj) && IsSetObjEmpty(obj)
129
+ ) {
130
+ console.warn(`ValuesOf(@obj: NO_ELEMENTS_FOUND): The specified object does not have any present elements or contents! (Exited with [])`);
131
+ return [];
132
+ }
133
+
134
+ // 📍 - @type = OBJECT
135
+ if (IsPlainObj(obj))
136
+ return Object.values(obj);
137
+
138
+ // 📍 - @type = ARRAY | MAP | SET
139
+ if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
140
+ return obj.values();
141
+
142
+ // 📍 - @type = undefined | null.
143
+ // 💬 - Default detection if type is not in the option (for module namespace, freezed objects, and no constructor objects)
144
+ if (IsNullOrUndefined(obj.constructor) || IsNullOrUndefined(Object.getPrototypeOf(obj)))
145
+ if (IsPlainObj(obj))
146
+ return Object.values(obj);
147
+ else if (IsArr(obj) || IsMapObj(obj) || IsSetObj(obj))
148
+ return obj.values();
149
+ else
150
+ return [];
151
+ }
152
+
153
+ /**
154
+ * Returns the current `size` or `length` of the specified argument.
155
+ *
156
+ * ***Known Objects or Types***:
157
+ * - ***ARRAY*** | ***PLAIN OBJECT*** | ***MAP OBJECT*** | ***SET OBJECT*** | ***STRING***
158
+ *
159
+ * ***Capability-Based Behavior***:
160
+ * - This accessor is **not strictly type-limited**.
161
+ * - Any value that exposes a numeric `length` or `size` property
162
+ * may be supported, including **custom user-defined objects**,
163
+ * **library abstractions**, **module namespaces**, and other
164
+ * object-like structures.
165
+ *
166
+ * ***Notes***:
167
+ * - The accessor prioritizes the `length` property when present,
168
+ * otherwise falls back to the `size` property.
169
+ * - A default value of `-1` is returned if the specified argument
170
+ * is invalid, unsupported, or exposes a non-numeric `length`
171
+ * or `size` property.
172
+ *
173
+ * @template T
174
+ * @param { T } arg - The argument to retrieve the current size or length from.
175
+ * @returns { number } The computed size or length, or `-1` on failure.
176
+ */
177
+ export function CountOf(arg) {
178
+ const Method = "CountOf";
179
+
180
+ // ❌ - Exits with default value if argument is not provided.
181
+ if (IsNullOrUndefined(arg))
182
+ return -1;
183
+
184
+ // ⚠️ - Warns and exit with default value if the argument does not support or have 'length' and 'size' property.
185
+ if ((typeof arg === "string" && IsNullOrUndefined(arg.length) || IsPlainObj(arg) && IsNullOrUndefined(Object.keys(arg).length)) && IsNullOrUndefined(arg.size)) {
186
+ console.warn(`${Method}(@arg: NOT_SUPPORTED): The provided argument of type '${ConstructorOrTypeOf(arg)}' does not support or have 'length' and/or 'size' property! (Exited with -1)`);
187
+ return -1;
188
+ }
189
+
190
+ // 📍 - length property.
191
+ if (Object.hasOwn(arg, "length") || IsPlainObj(arg)) {
192
+ const parsedLength = IsPlainObj(arg) ? parseInt(Object.entries(arg)["length"], 10) : parseInt(arg["length"]);
193
+ if (!IsNum(arg["length"]) && !IsNum(parsedLength)) {
194
+ console.warn(`CountOf(@arg.length): The length '${arg["length"]}' property value of the specified argument is not a valid number! (Exited with -1)`);
195
+ return -1;
196
+ }
197
+
198
+ return parsedLength;
199
+ }
200
+
201
+ // 📍 - size property.
202
+ if (Object.hasOwn(arg, "size")) {
203
+ const parsedSize = parseInt(arg["size"], 10);
204
+ if (!IsNum(arg["size"]) && !IsNum(parsedSize)) {
205
+ console.warn(`CountOf(@arg.size): The size '${arg["size"]}' property value of the specified argument is not a valid number! (Exited with -1)`);
206
+ return -1;
207
+ }
208
+
209
+ return parsedSize;
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Retrieves and returns the value of the specified property in the specified plain `object`.
215
+ *
216
+ * ***Notes***:
217
+ * - This uses a non-case-sensitive for retrieving the data of the specified property id at
218
+ * plain object, this would retrieve the data of the first property that matches the specified
219
+ * property id in any case.
220
+ * - Returns `undefined` if parameter `obj` or `propertyId` is invalid.
221
+ *
222
+ * @template T
223
+ * @template { InferKeyOptions<T> } P
224
+ * @param { T } obj - The collection of key-pairs to retrieve at.
225
+ * @param { P } propertyId - The property id of key-pair to retrieve.
226
+ * @returns { T[P] | undefined }
227
+ */
228
+ export function GetPropertyOf(obj, propertyId) {
229
+ if (!IsPlainObj(obj) || !IsStr(propertyId) || !IsStrEmpty(propertyId))
230
+ return undefined;
231
+
232
+ let Result;
233
+ for (const [PK, PV] of Object.entries(obj)) {
234
+ if (PK.trim().toLowerCase() !== propertyId.trim().toLowerCase())
235
+ continue;
236
+
237
+ Result = PV;
238
+ break;
239
+ }
240
+
241
+ return Result;
242
+ }
@@ -0,0 +1,148 @@
1
+ import Emit from '../../custom/error/builder/error.builder.js';
2
+ import { ConstructorOrTypeOf } from '../../custom/utils/custom.utils.js';
3
+ import { IsFuncAnonymous } from '../../guards/formats/formats.js';
4
+ import { IsArr, IsFunc, IsMapObj, IsNullOrUndefined, IsSetObj } from '../../guards/data-types/data-types.js';
5
+ import { CountOf } from './obj.accessor.js';
6
+
7
+ /* Parameters Id and Expected Object Formats */
8
+ const Args = ["obj", "callback", "thisArg"];
9
+ const ObjectFormats = ["Array", "Map", "Set"];
10
+
11
+ /**
12
+ * Iterates and perform the specified `callback function` on each of the elements of the specified `object`.
13
+ *
14
+ * @template T, A
15
+ * @param { T } obj - The object to get the elements from.
16
+ * @param { (value: IterableValue<T>, index: number, arr: IterableValue<T>[]) => void } callback - The callback function to perform.
17
+ * @param { A } [thisArg] - An optional parameter to hold the specified value and access it using the `this` keyword.
18
+ * @returns { void } - Does not return any data or value.
19
+ */
20
+ export function EachOf(obj, callback, thisArg) {
21
+ const Method = "EachOf";
22
+
23
+ // ❌ - Exits when the provided object is not valid or not supported.
24
+ if (!IsArr(obj) && !IsMapObj(obj) && !IsSetObj(obj) && !("forEach" in obj))
25
+ Emit._ArgumentError(Method, Args[0], ConstructorOrTypeOf(obj), ...ObjectFormats);
26
+
27
+ // ❌ - Exits when callback is not callable or function.
28
+ if (!IsFunc(callback))
29
+ Emit._ArgumentError(Method, Args[1], ConstructorOrTypeOf(callback), "Function");
30
+
31
+ // ⚠️ - Notify and terminate the continuation of this process when the provided object is empty.
32
+ if (!(obj instanceof Iterator) && CountOf(obj) <= 0) {
33
+ console.warn(`${Method}(${Args[0]}: EMPTY): No elements to iterate. (Terminated)`);
34
+ return;
35
+ }
36
+
37
+ // ⚠️ - Warns about possible conflicts when accessing or using the provided @thisArg inside of a anonymous @callback function.
38
+ if (!IsNullOrUndefined(thisArg) && IsFuncAnonymous(callback))
39
+ console.warn(`${Method}(@callback: anonymous): May throw or cause an error to your program if 'this' keyword is used inside of the anonymous callback function.`);
40
+
41
+ /* @Iterate */
42
+ obj["forEach"](callback, thisArg);
43
+ }
44
+
45
+ /**
46
+ * Iterates and perform the specified `callback function` on each of the elements of the specified `object`,
47
+ * and returns a new array that contains the result(s).
48
+ *
49
+ * @template T, A, U
50
+ * @param { T } obj - The object to get the elements from.
51
+ * @param { (value: IterableValue<T>, index: number, arr: IterableValue<T>[]) => U } callback - The callback function to perform.
52
+ * @param { A } [thisArg] - An optional parameter to hold the specified value and access it using the `this` keyword.
53
+ * @returns { U[] } - Returns a new array that contains the result(s).
54
+ */
55
+ export function MapOf(obj, callback, thisArg) {
56
+ const Method = "MapOf";
57
+
58
+ // ❌ - Exits when the provided object is not valid or not supported.
59
+ if (!IsArr(obj) && !IsMapObj(obj) && !IsSetObj(obj) && !("map" in obj))
60
+ Emit._ArgumentError(Method, Args[0], ConstructorOrTypeOf(obj), ...ObjectFormats);
61
+
62
+ // ❌ - Exits when callback is not callable or function.
63
+ if (!IsFunc(callback))
64
+ Emit._ArgumentError(Method, Args[1], ConstructorOrTypeOf(callback), "Function");
65
+
66
+ // ⚠️ - Notify and terminate the continuation of this process when the provided object is empty.
67
+ if (!(obj instanceof Iterator) && CountOf(obj) <= 0) {
68
+ console.warn(`${Method}(${Args[0]}: EMPTY): No elements to iterate. (Terminated)`);
69
+ return [];
70
+ }
71
+
72
+ // ⚠️ - Warns about possible conflicts when accessing or using the provided @thisArg inside of a anonymous @callback function.
73
+ if (!IsNullOrUndefined(thisArg) && IsFuncAnonymous(callback))
74
+ console.warn(`${Method}(@callback: anonymous): May throw or cause an error to your program if 'this' keyword is used inside of the anonymous callback function.`);
75
+
76
+ /* @Iterate */
77
+ return obj["map"](callback, thisArg);
78
+ }
79
+
80
+ /**
81
+ * Iterates and perform the specified `callback function` on each of the elements of the specified `object`,
82
+ * and determines whether if some of the elements in the `object` satisfies the specified `callback function`.
83
+ *
84
+ * @template T, A
85
+ * @param { T } obj - The object to get the elements from.
86
+ * @param { (value: IterableValue<T>, index: number, arr: IterableValue<T>[]) => unknown } callback - The callback function to perform.
87
+ * @param { A } [thisArg] - An optional parameter to hold the specified value and access it using the `this` keyword.
88
+ * @returns { boolean } - Returns `true` if some of the elements in the `object` satisfies the specified `callback function`, otherwise `false`.
89
+ */
90
+ export function SomeOf(obj, callback, thisArg) {
91
+ const Method = "SomeOf";
92
+
93
+ // ❌ - Exits when the provided object is not valid or not supported.
94
+ if (!IsArr(obj) && !IsMapObj(obj) && !IsSetObj(obj) && !("some" in obj))
95
+ Emit._ArgumentError(Method, Args[0], ConstructorOrTypeOf(obj), ...ObjectFormats);
96
+
97
+ // ❌ - Exits when callback is not callable or function.
98
+ if (!IsFunc(callback))
99
+ Emit._ArgumentError(Method, Args[1], ConstructorOrTypeOf(callback), "Function");
100
+
101
+ // ⚠️ - Notify and terminate the continuation of this process when the provided object is empty.
102
+ if (!(obj instanceof Iterator) && CountOf(obj) <= 0) {
103
+ console.warn(`${Method}(${Args[0]}: EMPTY): No elements to iterate. (Terminated)`);
104
+ return [];
105
+ }
106
+
107
+ // ⚠️ - Warns about possible conflicts when accessing or using the provided @thisArg inside of a anonymous @callback function.
108
+ if (!IsNullOrUndefined(thisArg) && IsFuncAnonymous(callback))
109
+ console.warn(`${Method}(@callback: anonymous): May throw or cause an error to your program if 'this' keyword is used inside of the anonymous callback function.`);
110
+
111
+ /* @Iterate */
112
+ return obj["some"](callback, thisArg);
113
+ }
114
+
115
+ /**
116
+ * Iterates and perform the specified `callback function` on each of the elements of the specified `object`,
117
+ * and determines whether if all of the elements in the `object` satisfies the specified `callback function`.
118
+ *
119
+ * @template T, A
120
+ * @param { T } obj - The object to get the elements from.
121
+ * @param { (value: IterableValue<T>, index: number, arr: IterableValue<T>[]) => unknown } callback - The callback function to perform.
122
+ * @param { A } [thisArg] - An optional parameter to hold the specified value and access it using the `this` keyword.
123
+ * @returns { boolean } - Returns `true` if all of the elements in the `object` satisfies the specified `callback function`, otherwise `false`.
124
+ */
125
+ export function EveryOf(obj, callback, thisArg) {
126
+ const Method = "EveryOf";
127
+
128
+ // ❌ - Exits when the provided object is not valid or not supported.
129
+ if (!IsArr(obj) && !IsMapObj(obj) && !IsSetObj(obj) && !("every" in obj))
130
+ Emit._ArgumentError(Method, Args[0], ConstructorOrTypeOf(obj), ...ObjectFormats);
131
+
132
+ // ❌ - Exits when callback is not callable or function.
133
+ if (!IsFunc(callback))
134
+ Emit._ArgumentError(Method, Args[1], ConstructorOrTypeOf(callback), "Function");
135
+
136
+ // ⚠️ - Notify and terminate the continuation of this process when the provided object is empty.
137
+ if (!(obj instanceof Iterator) && CountOf(obj) <= 0) {
138
+ console.warn(`${Method}(${Args[0]}: EMPTY): No elements to iterate. (Terminated)`);
139
+ return [];
140
+ }
141
+
142
+ // ⚠️ - Warns about possible conflicts when accessing or using the provided @thisArg inside of a anonymous @callback function.
143
+ if (!IsNullOrUndefined(thisArg) && IsFuncAnonymous(callback))
144
+ console.warn(`${Method}(@callback: anonymous): May throw or cause an error to your program if 'this' keyword is used inside of the anonymous callback function.`);
145
+
146
+ /* @Iterate */
147
+ return obj["every"](callback, thisArg);
148
+ }
@@ -0,0 +1,23 @@
1
+ import { DefineProperty, Global, NameOf } from '../custom/utils/custom.utils.js';
2
+ import { IsNullOrUndefined, IsPropertyAt } from '../guards/data-types/data-types.js';
3
+ import { IsStrEmpty } from '../guards/formats/formats.js';
4
+ import * as OAC from "./obj/obj.accessor.js";
5
+ import * as OI from "./obj/obj.iterator.js";
6
+ import STR from "./str/str.js";
7
+
8
+ /**
9
+ * Contains reusable primitives methods of ***array***, ***string***, and many more!.
10
+ */
11
+ export default function Primitives() {
12
+ const PrimitivesAPI = {};
13
+
14
+ for (const Method of [...Object.values(OAC), ...Object.values(OI), STR]) {
15
+ const Key = NameOf(Method);
16
+ if (!IsNullOrUndefined(Key) && !IsStrEmpty(Key) && !IsPropertyAt(PrimitivesAPI, Key) && !(Key === "(ANONYMOUS)"))
17
+ DefineProperty(PrimitivesAPI, Key, Method, "med");
18
+ }
19
+
20
+ Global("Primitives", PrimitivesAPI, "soft");
21
+ }
22
+
23
+ Primitives();
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Contains `@custom` and/or `@enhance` string methods.
3
+ */
4
+ const Str = {
5
+ /**
6
+ * Name of this object.
7
+ */
8
+ name: "Str",
9
+
10
+ /**
11
+ * Contains collection of characters. (E.g. Lowercase(): a-z)
12
+ */
13
+ Chars: {
14
+ /**
15
+ * Returns a set of character codes of `lowercase` characters.
16
+ *
17
+ * @returns { string } The set of `lowercase` characters.
18
+ */
19
+ Lowercase() {
20
+ return String.fromCharCode(...Array.from({ length: 26 }, (_, i) => i + 97));
21
+ },
22
+
23
+ /**
24
+ * Returns a set of character codes of `numeric` characters.
25
+ *
26
+ * @returns { string } The set of `numeric` characters.
27
+ */
28
+ Numeric() {
29
+ return String.fromCharCode(...Array.from({ length: 10 }, (_, i) => i + 48));
30
+ },
31
+
32
+ /**
33
+ * Returns a set of character codes of `special` or `symbol` characters.
34
+ *
35
+ * @returns { string } The set of `special` or `symbol` characters.
36
+ */
37
+ Symbols() {
38
+ return String.fromCharCode(...Array.from({ length: 15 }, (_, i) => i + 33)) + `=_[]@~{}<>?\\`;
39
+ },
40
+
41
+ /**
42
+ * Returns a set of character codes of `uppercase` characters.
43
+ *
44
+ * @returns { string } The set of `uppercase` characters.
45
+ */
46
+ Uppercase() {
47
+ return String.fromCharCode(...Array.from({ length: 26 }, (_, i) => i + 65));
48
+ },
49
+ },
50
+ }
51
+
52
+ export default Str;