@ix-xs/node-comfort 1.1.3 → 1.2.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.
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Splits an array into chunks of a given size.
3
+ *
4
+ * @example
5
+ * nodeComfort.arr.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
6
+ *
7
+ * @param {any[]} array - Source array.
8
+ * @param {number} size - Chunk size (must be >= 1).
9
+ * @returns {any[][]} The chunked array.
10
+ */
11
+ export function chunk(array: any[], size: number): any[][];
12
+ /**
13
+ * Returns a new array with duplicate values removed.
14
+ *
15
+ * Pass an `iteratee` to de-duplicate by a derived key.
16
+ *
17
+ * @example
18
+ * nodeComfort.arr.unique([1, 1, 2, 3]); // [1, 2, 3]
19
+ * nodeComfort.arr.unique([{ id: 1 }, { id: 1 }], "id"); // [{ id: 1 }]
20
+ *
21
+ * @param {any[]} array - Source array.
22
+ * @param {string|((item: any) => any)} [iteratee] - Key or function to compare by.
23
+ * @returns {any[]} The de-duplicated array.
24
+ */
25
+ export function unique(array: any[], iteratee?: string | ((item: any) => any)): any[];
26
+ /**
27
+ * Groups the items of an array by a key or function.
28
+ *
29
+ * @example
30
+ * nodeComfort.arr.groupBy([1, 2, 3, 4], (n) => (n % 2 ? "odd" : "even"));
31
+ * // { odd: [1, 3], even: [2, 4] }
32
+ *
33
+ * @param {any[]} array - Source array.
34
+ * @param {string|((item: any) => any)} iteratee - Key or function to group by.
35
+ * @returns {Record<string, any[]>} The grouped object.
36
+ */
37
+ export function groupBy(array: any[], iteratee: string | ((item: any) => any)): Record<string, any[]>;
38
+ /**
39
+ * Builds an object keyed by a derived value, mapping each key to the
40
+ * (last) matching item.
41
+ *
42
+ * @example
43
+ * nodeComfort.arr.keyBy([{ id: "a" }, { id: "b" }], "id");
44
+ * // { a: { id: "a" }, b: { id: "b" } }
45
+ *
46
+ * @param {any[]} array - Source array.
47
+ * @param {string|((item: any) => any)} iteratee - Key or function.
48
+ * @returns {Record<string, any>} The keyed object.
49
+ */
50
+ export function keyBy(array: any[], iteratee: string | ((item: any) => any)): Record<string, any>;
51
+ /**
52
+ * Partitions an array into two groups based on a predicate:
53
+ * `[matching, notMatching]`.
54
+ *
55
+ * @example
56
+ * nodeComfort.arr.partition([1, 2, 3, 4], (n) => n % 2 === 0);
57
+ * // [[2, 4], [1, 3]]
58
+ *
59
+ * @param {any[]} array - Source array.
60
+ * @param {(item: any, index: number) => boolean} predicate - Test function.
61
+ * @returns {[any[], any[]]} The two partitions.
62
+ */
63
+ export function partition(array: any[], predicate: (item: any, index: number) => boolean): [any[], any[]];
64
+ /**
65
+ * Recursively flattens a nested array up to a given depth.
66
+ *
67
+ * @example
68
+ * nodeComfort.arr.flatten([1, [2, [3, [4]]]]); // [1, 2, 3, [4]]
69
+ * nodeComfort.arr.flatten([1, [2, [3]]], Infinity); // [1, 2, 3]
70
+ *
71
+ * @param {any[]} array - Source array.
72
+ * @param {number} [depth=1] - Maximum depth to flatten.
73
+ * @returns {any[]} The flattened array.
74
+ */
75
+ export function flatten(array: any[], depth?: number): any[];
76
+ /**
77
+ * Returns a shuffled copy of an array (Fisher–Yates).
78
+ *
79
+ * Uses `Math.random` • not cryptographically secure.
80
+ *
81
+ * @param {any[]} array - Source array.
82
+ * @returns {any[]} A new shuffled array.
83
+ */
84
+ export function shuffle(array: any[]): any[];
85
+ /**
86
+ * Returns a random element from an array.
87
+ *
88
+ * @param {any[]} array - Source array.
89
+ * @returns {any} A random element, or undefined if empty.
90
+ */
91
+ export function sample(array: any[]): any;
92
+ /**
93
+ * Returns `n` random elements from an array (without repetition).
94
+ *
95
+ * @param {any[]} array - Source array.
96
+ * @param {number} n - Number of elements to pick.
97
+ * @returns {any[]} The sampled elements.
98
+ */
99
+ export function sampleSize(array: any[], n: number): any[];
100
+ /**
101
+ * Sorts an array by one or more iteratees, ascending by default.
102
+ *
103
+ * Does not mutate the input.
104
+ *
105
+ * @example
106
+ * nodeComfort.arr.sortBy(users, "age");
107
+ * nodeComfort.arr.sortBy(users, [(u) => u.age, "name"]);
108
+ *
109
+ * @param {any[]} array - Source array.
110
+ * @param {string|((item: any) => any)|Array<string|((item: any) => any)>} iteratees - Sort key(s).
111
+ * @param {"asc"|"desc"} [direction="asc"] - Sort direction.
112
+ * @returns {any[]} A new sorted array.
113
+ */
114
+ export function sortBy(array: any[], iteratees: string | ((item: any) => any) | Array<string | ((item: any) => any)>, direction?: "asc" | "desc"): any[];
115
+ /**
116
+ * Returns the elements present in the first array but not in the others.
117
+ *
118
+ * @example
119
+ * nodeComfort.arr.difference([1, 2, 3, 4], [2, 4]); // [1, 3]
120
+ *
121
+ * @param {any[]} array - Source array.
122
+ * @param {...any[]} others - Arrays to subtract.
123
+ * @returns {any[]} The difference.
124
+ */
125
+ export function difference(array: any[], ...others: any[][]): any[];
126
+ /**
127
+ * Returns the elements common to all provided arrays.
128
+ *
129
+ * @example
130
+ * nodeComfort.arr.intersection([1, 2, 3], [2, 3, 4]); // [2, 3]
131
+ *
132
+ * @param {...any[]} arrays - Arrays to intersect.
133
+ * @returns {any[]} The intersection.
134
+ */
135
+ export function intersection(...arrays: any[][]): any[];
136
+ /**
137
+ * Returns the union (unique values) of all provided arrays.
138
+ *
139
+ * @example
140
+ * nodeComfort.arr.union([1, 2], [2, 3], [3, 4]); // [1, 2, 3, 4]
141
+ *
142
+ * @param {...any[]} arrays - Arrays to unite.
143
+ * @returns {any[]} The union.
144
+ */
145
+ export function union(...arrays: any[][]): any[];
146
+ /**
147
+ * Zips multiple arrays together into an array of tuples.
148
+ *
149
+ * @example
150
+ * nodeComfort.arr.zip(["a", "b"], [1, 2]); // [["a", 1], ["b", 2]]
151
+ *
152
+ * @param {...any[]} arrays - Arrays to zip.
153
+ * @returns {any[][]} The zipped tuples.
154
+ */
155
+ export function zip(...arrays: any[][]): any[][];
156
+ /**
157
+ * Splits an array into `matching` and removes falsy values.
158
+ *
159
+ * Removes `false`, `null`, `0`, `""`, `undefined` and `NaN`.
160
+ *
161
+ * @example
162
+ * nodeComfort.arr.compact([0, 1, false, 2, "", 3, null]); // [1, 2, 3]
163
+ *
164
+ * @param {any[]} array - Source array.
165
+ * @returns {any[]} The compacted array.
166
+ */
167
+ export function compact(array: any[]): any[];
168
+ /**
169
+ * Returns the first element (or the first `n` elements) of an array.
170
+ *
171
+ * @param {any[]} array - Source array.
172
+ * @param {number} [n] - How many elements to take.
173
+ * @returns {any} The first element, or the first `n` elements when `n` is given.
174
+ */
175
+ export function first(array: any[], n?: number): any;
176
+ /**
177
+ * Returns the last element (or the last `n` elements) of an array.
178
+ *
179
+ * @param {any[]} array - Source array.
180
+ * @param {number} [n] - How many elements to take.
181
+ * @returns {any} The last element, or the last `n` elements when `n` is given.
182
+ */
183
+ export function last(array: any[], n?: number): any;
184
+ /**
185
+ * Removes items from an array where the predicate is true, returning a new array.
186
+ *
187
+ * @param {any[]} array - Source array.
188
+ * @param {(item: any, index: number) => boolean} predicate - Removal test.
189
+ * @returns {any[]} A new array without the removed items.
190
+ */
191
+ export function remove(array: any[], predicate: (item: any, index: number) => boolean): any[];
192
+ /**
193
+ * Moves an element from one index to another (returns a new array).
194
+ *
195
+ * @param {any[]} array - Source array.
196
+ * @param {number} from - Source index.
197
+ * @param {number} to - Destination index.
198
+ * @returns {any[]} The reordered array.
199
+ */
200
+ export function move(array: any[], from: number, to: number): any[];
201
+ /**
202
+ * Counts occurrences of each derived key in an array.
203
+ *
204
+ * @example
205
+ * nodeComfort.arr.countBy(["a", "b", "a"]); // { a: 2, b: 1 }
206
+ * nodeComfort.arr.countBy([1.1, 2.3, 1.7], Math.floor); // { 1: 2, 2: 1 }
207
+ *
208
+ * @param {any[]} array - Source array.
209
+ * @param {string|((item: any) => any)} [iteratee] - Key or function.
210
+ * @returns {Record<string, number>} The counts.
211
+ */
212
+ export function countBy(array: any[], iteratee?: string | ((item: any) => any)): Record<string, number>;
213
+ /**
214
+ * Sums an array by a numeric iteratee (or the values themselves).
215
+ *
216
+ * @example
217
+ * nodeComfort.arr.sumBy([{ n: 1 }, { n: 2 }], "n"); // 3
218
+ *
219
+ * @param {any[]} array - Source array.
220
+ * @param {string|((item: any) => number)} [iteratee] - Key or function returning a number.
221
+ * @returns {number} The sum.
222
+ */
223
+ export function sumBy(array: any[], iteratee?: string | ((item: any) => number)): number;
224
+ /**
225
+ * Returns the item with the maximum derived value.
226
+ *
227
+ * @param {any[]} array - Source array.
228
+ * @param {string|((item: any) => number)} [iteratee] - Key or function.
229
+ * @returns {any} The item, or undefined if the array is empty.
230
+ */
231
+ export function maxBy(array: any[], iteratee?: string | ((item: any) => number)): any;
232
+ /**
233
+ * Returns the item with the minimum derived value.
234
+ *
235
+ * @param {any[]} array - Source array.
236
+ * @param {string|((item: any) => number)} [iteratee] - Key or function.
237
+ * @returns {any} The item, or undefined if the array is empty.
238
+ */
239
+ export function minBy(array: any[], iteratee?: string | ((item: any) => number)): any;
240
+ /**
241
+ * Creates an array of a given length, filled by a value or generator function.
242
+ *
243
+ * @example
244
+ * nodeComfort.arr.times(3, "x"); // ["x", "x", "x"]
245
+ * nodeComfort.arr.times(3, (i) => i * 2); // [0, 2, 4]
246
+ *
247
+ * @param {number} n - Number of items.
248
+ * @param {any|((index: number) => any)} [value] - Fill value or generator.
249
+ * @returns {any[]} The generated array.
250
+ */
251
+ export function times(n: number, value?: any | ((index: number) => any)): any[];
252
+ //# sourceMappingURL=Arr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Arr.d.ts","sourceRoot":"","sources":["../../src/Arr.js"],"names":[],"mappings":"AAuBE;;;;;;;;;GASG;AACH,6BAJW,GAAG,EAAE,QACL,MAAM,GACJ,GAAG,EAAE,EAAE,CASnB;AAED;;;;;;;;;;;;GAYG;AACH,8BAJW,GAAG,EAAE,aACL,MAAM,GAAC,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,GACzB,GAAG,EAAE,CAejB;AAED;;;;;;;;;;GA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Array.
3
+ *
4
+ * @example
5
+ * nodeComfort.isArray([1, 2, 3]); // true
6
+ * nodeComfort.isArray("not array"); // false
7
+ *
8
+ * @param {*} value - Value to check.
9
+ * @returns {boolean} True if the value is an Array.
10
+ */
11
+ export function isArray(value: any): boolean;
12
+ /**
13
+ * Checks if a value is a number (excluding NaN).
14
+ *
15
+ * @example
16
+ * nodeComfort.isNumber(42); // true
17
+ * nodeComfort.isNumber(NaN); // false
18
+ * nodeComfort.isNumber("42"); // false
19
+ *
20
+ * @param {*} value - Value to check.
21
+ * @returns {boolean} True if the value is a finite number or Infinity/-Infinity.
22
+ */
23
+ export function isNumber(value: any): boolean;
24
+ /**
25
+ * Checks if a value is a finite number (excludes NaN, Infinity and -Infinity).
26
+ *
27
+ * @example
28
+ * nodeComfort.isFinite(42); // true
29
+ * nodeComfort.isFinite(Infinity); // false
30
+ *
31
+ * @param {*} value - Value to check.
32
+ * @returns {boolean} True if the value is a finite number.
33
+ */
34
+ export function isFinite(value: any): boolean;
35
+ /**
36
+ * Checks if a value is a safe integer.
37
+ *
38
+ * @example
39
+ * nodeComfort.isInteger(42); // true
40
+ * nodeComfort.isInteger(4.2); // false
41
+ *
42
+ * @param {*} value - Value to check.
43
+ * @returns {boolean} True if the value is an integer.
44
+ */
45
+ export function isInteger(value: any): boolean;
46
+ /**
47
+ * Checks if a value is a floating-point number (a finite non-integer number).
48
+ *
49
+ * @example
50
+ * nodeComfort.isFloat(4.2); // true
51
+ * nodeComfort.isFloat(4); // false
52
+ *
53
+ * @param {*} value - Value to check.
54
+ * @returns {boolean} True if the value is a non-integer finite number.
55
+ */
56
+ export function isFloat(value: any): boolean;
57
+ /**
58
+ * Checks if a value is a function.
59
+ *
60
+ * @example
61
+ * nodeComfort.isFunction(() => {}); // true
62
+ * nodeComfort.isFunction(class {}); // true
63
+ * nodeComfort.isFunction("fn"); // false
64
+ *
65
+ * @param {*} value - Value to check.
66
+ * @returns {boolean} True if the value is a function.
67
+ */
68
+ export function isFunction(value: any): boolean;
69
+ /**
70
+ * Checks if a value is an async function (declared with `async`).
71
+ *
72
+ * @example
73
+ * nodeComfort.isAsyncFunction(async () => {}); // true
74
+ * nodeComfort.isAsyncFunction(() => {}); // false
75
+ *
76
+ * @param {*} value - Value to check.
77
+ * @returns {boolean} True if the value is an async function.
78
+ */
79
+ export function isAsyncFunction(value: any): boolean;
80
+ /**
81
+ * Checks if a value is a non-null object.
82
+ *
83
+ * Note: Arrays, Maps, Sets, Dates, etc. are also considered objects here.
84
+ *
85
+ * @example
86
+ * nodeComfort.isObject({}); // true
87
+ * nodeComfort.isObject([]); // true
88
+ * nodeComfort.isObject(null); // false
89
+ * nodeComfort.isObject("str"); // false
90
+ *
91
+ * @param {*} value - Value to check.
92
+ * @returns {boolean} True if the value is a non-null object.
93
+ */
94
+ export function isObject(value: any): boolean;
95
+ /**
96
+ * Checks if a value is a plain object (created via `{}` or `new Object()`).
97
+ *
98
+ * Unlike {@link isObject}, this excludes arrays, Maps, Dates, class instances, etc.
99
+ *
100
+ * @example
101
+ * nodeComfort.isPlainObject({ a: 1 }); // true
102
+ * nodeComfort.isPlainObject([]); // false
103
+ * nodeComfort.isPlainObject(new Date()); // false
104
+ *
105
+ * @param {*} value - Value to check.
106
+ * @returns {boolean} True if the value is a plain object.
107
+ */
108
+ export function isPlainObject(value: any): boolean;
109
+ /**
110
+ * Checks if a value is a boolean.
111
+ *
112
+ * @example
113
+ * nodeComfort.isBoolean(true); // true
114
+ * nodeComfort.isBoolean(false); // true
115
+ * nodeComfort.isBoolean(0); // false
116
+ *
117
+ * @param {*} value - Value to check.
118
+ * @returns {boolean} True if the value is a boolean.
119
+ */
120
+ export function isBoolean(value: any): boolean;
121
+ /**
122
+ * Checks if a value is a string.
123
+ *
124
+ * @example
125
+ * nodeComfort.isString("hello"); // true
126
+ * nodeComfort.isString(123); // false
127
+ *
128
+ * @param {*} value - Value to check.
129
+ * @returns {boolean} True if the value is a string.
130
+ */
131
+ export function isString(value: any): boolean;
132
+ /**
133
+ * Checks if a value is a symbol.
134
+ *
135
+ * @example
136
+ * nodeComfort.isSymbol(Symbol("x")); // true
137
+ *
138
+ * @param {*} value - Value to check.
139
+ * @returns {boolean} True if the value is a symbol.
140
+ */
141
+ export function isSymbol(value: any): boolean;
142
+ /**
143
+ * Checks if a value is a BigInt.
144
+ *
145
+ * @example
146
+ * nodeComfort.isBigInt(10n); // true
147
+ * nodeComfort.isBigInt(10); // false
148
+ *
149
+ * @param {*} value - Value to check.
150
+ * @returns {boolean} True if the value is a BigInt.
151
+ */
152
+ export function isBigInt(value: any): boolean;
153
+ /**
154
+ * Checks if a value is exactly undefined.
155
+ *
156
+ * @example
157
+ * nodeComfort.isUndefined(undefined); // true
158
+ * nodeComfort.isUndefined(null); // false
159
+ *
160
+ * @param {*} value - Value to check.
161
+ * @returns {boolean} True if the value is undefined.
162
+ */
163
+ export function isUndefined(value: any): boolean;
164
+ /**
165
+ * Checks if a value is exactly null.
166
+ *
167
+ * @example
168
+ * nodeComfort.isNull(null); // true
169
+ * nodeComfort.isNull(undefined); // false
170
+ *
171
+ * @param {*} value - Value to check.
172
+ * @returns {boolean} True if the value is null.
173
+ */
174
+ export function isNull(value: any): boolean;
175
+ /**
176
+ * Checks if a value is `null` or `undefined`.
177
+ *
178
+ * @example
179
+ * nodeComfort.isNil(null); // true
180
+ * nodeComfort.isNil(undefined); // true
181
+ * nodeComfort.isNil(0); // false
182
+ *
183
+ * @param {*} value - Value to check.
184
+ * @returns {boolean} True if the value is null or undefined.
185
+ */
186
+ export function isNil(value: any): boolean;
187
+ /**
188
+ * Checks if a value is a primitive (string, number, boolean, symbol, bigint, null or undefined).
189
+ *
190
+ * @example
191
+ * nodeComfort.isPrimitive(42); // true
192
+ * nodeComfort.isPrimitive({}); // false
193
+ *
194
+ * @param {*} value - Value to check.
195
+ * @returns {boolean} True if the value is a primitive.
196
+ */
197
+ export function isPrimitive(value: any): boolean;
198
+ /**
199
+ * Checks if a value is a Promise (or a thenable object).
200
+ *
201
+ * @example
202
+ * nodeComfort.isPromise(Promise.resolve()); // true
203
+ * nodeComfort.isPromise({ then() {} }); // true
204
+ * nodeComfort.isPromise(42); // false
205
+ *
206
+ * @param {*} value - Value to check.
207
+ * @returns {boolean} True if the value is a Promise or thenable.
208
+ */
209
+ export function isPromise(value: any): boolean;
210
+ /**
211
+ * Checks if a value is a RegExp instance.
212
+ *
213
+ * @example
214
+ * nodeComfort.isRegExp(/a/); // true
215
+ * nodeComfort.isRegExp("a"); // false
216
+ *
217
+ * @param {*} value - Value to check.
218
+ * @returns {boolean} True if the value is a RegExp.
219
+ */
220
+ export function isRegExp(value: any): boolean;
221
+ /**
222
+ * Checks if a value is a built-in Date instance.
223
+ *
224
+ * Uses `util.types.isDate` under the hood to handle cross-realm Dates.
225
+ *
226
+ * @example
227
+ * nodeComfort.isDate(new Date()); // true
228
+ * nodeComfort.isDate("2024-01-01"); // false
229
+ *
230
+ * @param {*} value - Value to check.
231
+ * @returns {boolean} True if the value is a Date instance.
232
+ */
233
+ export function isDate(value: any): boolean;
234
+ /**
235
+ * Checks if a value is a **valid** Date (a Date instance that is not `Invalid Date`).
236
+ *
237
+ * @example
238
+ * nodeComfort.isValidDate(new Date()); // true
239
+ * nodeComfort.isValidDate(new Date("nope")); // false
240
+ *
241
+ * @param {*} value - Value to check.
242
+ * @returns {boolean} True if the value is a valid Date.
243
+ */
244
+ export function isValidDate(value: any): boolean;
245
+ /**
246
+ * Checks if a value is a built-in Map instance.
247
+ *
248
+ * @example
249
+ * nodeComfort.isMap(new Map()); // true
250
+ * nodeComfort.isMap({}); // false
251
+ *
252
+ * @param {*} value - Value to check.
253
+ * @returns {boolean} True if the value is a Map.
254
+ */
255
+ export function isMap(value: any): boolean;
256
+ /**
257
+ * Checks if a value is a built-in Set instance.
258
+ *
259
+ * @example
260
+ * nodeComfort.isSet(new Set()); // true
261
+ * nodeComfort.isSet([]); // false
262
+ *
263
+ * @param {*} value - Value to check.
264
+ * @returns {boolean} True if the value is a Set.
265
+ */
266
+ export function isSet(value: any): boolean;
267
+ /**
268
+ * Checks if a value is a WeakMap instance.
269
+ *
270
+ * @param {*} value - Value to check.
271
+ * @returns {boolean} True if the value is a WeakMap.
272
+ */
273
+ export function isWeakMap(value: any): boolean;
274
+ /**
275
+ * Checks if a value is a WeakSet instance.
276
+ *
277
+ * @param {*} value - Value to check.
278
+ * @returns {boolean} True if the value is a WeakSet.
279
+ */
280
+ export function isWeakSet(value: any): boolean;
281
+ /**
282
+ * Checks if a value is an iterable (has a `Symbol.iterator`).
283
+ *
284
+ * Strings, arrays, Maps, Sets and generators are iterable.
285
+ *
286
+ * @example
287
+ * nodeComfort.isIterable([1, 2]); // true
288
+ * nodeComfort.isIterable("hi"); // true
289
+ * nodeComfort.isIterable({}); // false
290
+ *
291
+ * @param {*} value - Value to check.
292
+ * @returns {boolean} True if the value is iterable.
293
+ */
294
+ export function isIterable(value: any): boolean;
295
+ /**
296
+ * Checks if a value is a Node.js Buffer.
297
+ *
298
+ * @param {*} value - Value to check.
299
+ * @returns {boolean} True if the value is a Buffer.
300
+ */
301
+ export function isBuffer(value: any): boolean;
302
+ /**
303
+ * Checks if a value is any TypedArray (Uint8Array, Float64Array, etc.).
304
+ *
305
+ * @param {*} value - Value to check.
306
+ * @returns {boolean} True if the value is a TypedArray.
307
+ */
308
+ export function isTypedArray(value: any): boolean;
309
+ /**
310
+ * Checks if a value is a native Error instance.
311
+ *
312
+ * Uses `util.types.isNativeError` to correctly handle errors from other realms.
313
+ *
314
+ * @example
315
+ * nodeComfort.isError(new Error("x")); // true
316
+ * nodeComfort.isError(new TypeError("x")); // true
317
+ * nodeComfort.isError({ message: "x" }); // false
318
+ *
319
+ * @param {*} value - Value to check.
320
+ * @returns {boolean} True if the value is a native Error.
321
+ */
322
+ export function isError(value: any): boolean;
323
+ /**
324
+ * Checks if a value is "empty".
325
+ *
326
+ * Emptiness rules:
327
+ * - `null` / `undefined` -> empty
328
+ * - string / array -> empty when `length === 0`
329
+ * - Map / Set -> empty when `size === 0`
330
+ * - plain object -> empty when it has no own enumerable keys
331
+ * - anything else (numbers, booleans, functions, ...) -> never empty
332
+ *
333
+ * @example
334
+ * nodeComfort.isEmpty(""); // true
335
+ * nodeComfort.isEmpty([]); // true
336
+ * nodeComfort.isEmpty({}); // true
337
+ * nodeComfort.isEmpty(new Map()); // true
338
+ * nodeComfort.isEmpty("x"); // false
339
+ * nodeComfort.isEmpty(0); // false
340
+ *
341
+ * @param {*} value - Value to check.
342
+ * @returns {boolean} True if the value is considered empty.
343
+ */
344
+ export function isEmpty(value: any): boolean;
345
+ /**
346
+ * Checks if a string is a valid, well-formed email address.
347
+ *
348
+ * This is a pragmatic check (not a full RFC 5322 parser) that covers the
349
+ * vast majority of real-world addresses.
350
+ *
351
+ * @example
352
+ * nodeComfort.isEmail("john@example.com"); // true
353
+ * nodeComfort.isEmail("nope"); // false
354
+ *
355
+ * @param {*} value - Value to check.
356
+ * @returns {boolean} True if the value looks like an email address.
357
+ */
358
+ export function isEmail(value: any): boolean;
359
+ /**
360
+ * Checks if a string is a valid HTTP(S) URL.
361
+ *
362
+ * @example
363
+ * nodeComfort.isURL("https://example.com"); // true
364
+ * nodeComfort.isURL("ftp://example.com"); // false (not http/https)
365
+ *
366
+ * @param {*} value - Value to check.
367
+ * @param {{ protocols?: string[] }} [options] - Allowed protocols (default: http, https).
368
+ * @returns {boolean} True if the value is a valid URL with an allowed protocol.
369
+ */
370
+ export function isURL(value: any, options?: {
371
+ protocols?: string[];
372
+ }): boolean;
373
+ /**
374
+ * Checks if a string is a valid UUID (versions 1-5, any variant).
375
+ *
376
+ * @example
377
+ * nodeComfort.isUUID("123e4567-e89b-12d3-a456-426614174000"); // true
378
+ *
379
+ * @param {*} value - Value to check.
380
+ * @returns {boolean} True if the value is a UUID.
381
+ */
382
+ export function isUUID(value: any): boolean;
383
+ /**
384
+ * Checks if a string is valid, parseable JSON.
385
+ *
386
+ * @example
387
+ * nodeComfort.isJSON('{"a":1}'); // true
388
+ * nodeComfort.isJSON("{a:1}"); // false
389
+ *
390
+ * @param {*} value - Value to check.
391
+ * @returns {boolean} True if the value is a JSON-parseable string.
392
+ */
393
+ export function isJSON(value: any): boolean;
394
+ /**
395
+ * Checks if a value is numeric • a number, or a string that fully represents one.
396
+ *
397
+ * @example
398
+ * nodeComfort.isNumeric(42); // true
399
+ * nodeComfort.isNumeric("42"); // true
400
+ * nodeComfort.isNumeric("4.2e3"); // true
401
+ * nodeComfort.isNumeric("4px"); // false
402
+ *
403
+ * @param {*} value - Value to check.
404
+ * @returns {boolean} True if the value is numeric.
405
+ */
406
+ export function isNumeric(value: any): boolean;
407
+ //# sourceMappingURL=Checker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checker.d.ts","sourceRoot":"","sources":["../../src/Checker.js"],"names":[],"mappings":"AAUE;;;;;;;;;GASG;AACH,+BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;GAUG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,iCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,+BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;GAUG;AACH,kCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,uCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;;;;GAaG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;;;GAYG;AACH,qCAHW,GAAC,GACC,OAAO,CAMnB;AAED;;;;;;;;;;GAUG;AACH,iCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;GAQG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,gCAHW,GAAC,GACC,OAAO,CAIn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