@tolki/utils 1.0.2 → 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.
- package/README.md +2 -0
- package/dist/cast.d.ts +83 -0
- package/dist/cast.d.ts.map +1 -0
- package/dist/cast.js +30 -0
- package/dist/equality.d.ts +51 -0
- package/dist/equality.d.ts.map +1 -0
- package/dist/equality.js +75 -0
- package/dist/guards.d.ts +353 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +116 -0
- package/dist/index.js +53 -45
- package/dist/keys.d.ts +36 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +25 -0
- package/dist/reflect.d.ts +26 -0
- package/dist/reflect.d.ts.map +1 -0
- package/dist/reflect.js +11 -0
- package/dist/string.d.ts +17 -0
- package/dist/string.d.ts.map +1 -0
- package/dist/string.js +20 -0
- package/dist/utils.d.ts +6 -521
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +53 -242
- package/package.json +2 -2
package/dist/utils.d.ts
CHANGED
|
@@ -1,522 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export declare function isArray<T>(value: DataItems<T> | T[] | unknown): value is T[];
|
|
9
|
-
/**
|
|
10
|
-
* Check if a value is an object (not null, not array).
|
|
11
|
-
*
|
|
12
|
-
* @param value - The value to check
|
|
13
|
-
* @returns True if the value is an object
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
*
|
|
17
|
-
* isObject({a: 1, b: 2}); -> true
|
|
18
|
-
* isObject([1, 2, 3]); -> false
|
|
19
|
-
* isObject(null); -> false
|
|
20
|
-
*/
|
|
21
|
-
export declare function isObject<T, K extends PropertyKey = PropertyKey>(value: DataItems<T, K> | unknown): value is Record<K, T>;
|
|
22
|
-
/**
|
|
23
|
-
* Check if a value is any object (including arrays, null).
|
|
24
|
-
*
|
|
25
|
-
* @param value - The value to check
|
|
26
|
-
* @returns True if the value is any object
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
*
|
|
30
|
-
* isObjectAny({a: 1, b: 2}); -> true
|
|
31
|
-
* isObjectAny([1, 2, 3]); -> true
|
|
32
|
-
* isObjectAny(null); -> true
|
|
33
|
-
*/
|
|
34
|
-
export declare function isObjectAny(value: unknown): value is object;
|
|
35
|
-
/**
|
|
36
|
-
* Check if a value is a truthy object (not null, not undefined, and an object).
|
|
37
|
-
*
|
|
38
|
-
* @param value - The value to check
|
|
39
|
-
* @returns True if the value is a truthy object
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
*
|
|
43
|
-
* isTruthyObject({a: 1, b: 2}); -> true
|
|
44
|
-
* isTruthyObject([1, 2, 3]); -> true
|
|
45
|
-
* isTruthyObject(null); -> false
|
|
46
|
-
* isTruthyObject(undefined); -> false
|
|
47
|
-
*/
|
|
48
|
-
export declare function isTruthyObject(value: unknown): value is object;
|
|
49
|
-
/**
|
|
50
|
-
* Check if a value is a string.
|
|
51
|
-
*
|
|
52
|
-
* @param value - The value to check
|
|
53
|
-
* @returns True if the value is a string
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
*
|
|
57
|
-
* isString("hello"); -> true
|
|
58
|
-
* isString(123); -> false
|
|
59
|
-
* isString(null); -> false
|
|
60
|
-
*/
|
|
61
|
-
export declare function isString(value: unknown): value is string;
|
|
62
|
-
/**
|
|
63
|
-
* Convert a string to lower-case.
|
|
64
|
-
*/
|
|
65
|
-
export declare function toLower(value: string): string;
|
|
66
|
-
/**
|
|
67
|
-
* Convert a string to upper-case.
|
|
68
|
-
*/
|
|
69
|
-
export declare function toUpper(value: string): string;
|
|
70
|
-
/**
|
|
71
|
-
* Convert the first character of a string to lower-case.
|
|
72
|
-
*/
|
|
73
|
-
export declare function lowerFirst(value: string): string;
|
|
74
|
-
/**
|
|
75
|
-
* Convert the first character of a string to upper-case.
|
|
76
|
-
*/
|
|
77
|
-
export declare function upperFirst(value: string): string;
|
|
78
|
-
/**
|
|
79
|
-
* Check if a value is stringable (can be converted to a string).
|
|
80
|
-
*
|
|
81
|
-
* @param value - The value to check
|
|
82
|
-
* @returns True if the value is stringable
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
*
|
|
86
|
-
* isStringable("hello"); -> true
|
|
87
|
-
* isStringable(new Stringable('test')); -> true
|
|
88
|
-
* isStringable({ toString: () => "world" }); -> true
|
|
89
|
-
* isStringable(123); -> false
|
|
90
|
-
* isStringable(null); -> false
|
|
91
|
-
*/
|
|
92
|
-
export declare function isStringable(value: unknown): value is string | {
|
|
93
|
-
toString(): string;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Check if a value is an object with a toString method.
|
|
97
|
-
*
|
|
98
|
-
* @param value - The value to check
|
|
99
|
-
* @returns True if the value is an object with a toString method
|
|
100
|
-
*/
|
|
101
|
-
export declare function objectToString(value: unknown): value is {
|
|
102
|
-
toString(): string;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Check if a value is a number (and not NaN).
|
|
106
|
-
*
|
|
107
|
-
* @param value - The value to check
|
|
108
|
-
* @returns True if the value is a valid number
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
*
|
|
112
|
-
* isNumber(123); -> true
|
|
113
|
-
* isNumber(3.14); -> true
|
|
114
|
-
* isNumber(NaN); -> false
|
|
115
|
-
* isNumber("123"); -> false
|
|
116
|
-
*/
|
|
117
|
-
export declare function isNumber(value: unknown): value is number;
|
|
118
|
-
/**
|
|
119
|
-
* Check if a value is an integer.
|
|
120
|
-
*
|
|
121
|
-
* @param value - The value to check
|
|
122
|
-
* @returns True if the value is an integer
|
|
123
|
-
*/
|
|
124
|
-
export declare function isInteger(value: unknown): value is number;
|
|
125
|
-
/**
|
|
126
|
-
* Check if a value is a float.
|
|
127
|
-
*
|
|
128
|
-
* @param value - The value to check
|
|
129
|
-
* @returns True if the value is a float
|
|
130
|
-
*/
|
|
131
|
-
export declare function isFloat(value: unknown): value is number;
|
|
132
|
-
/**
|
|
133
|
-
* Check if a value is a positive number.
|
|
134
|
-
*
|
|
135
|
-
* @param value - The value to check
|
|
136
|
-
* @returns True if the value is a positive number
|
|
137
|
-
*/
|
|
138
|
-
export declare function isPositiveNumber(value: unknown): value is number;
|
|
139
|
-
/**
|
|
140
|
-
* Check if a value is a negative number.
|
|
141
|
-
*
|
|
142
|
-
* @param value - The value to check
|
|
143
|
-
* @returns True if the value is a negative number
|
|
144
|
-
*/
|
|
145
|
-
export declare function isNegativeNumber(value: unknown): value is number;
|
|
146
|
-
/**
|
|
147
|
-
* Check if a value is a boolean.
|
|
148
|
-
*
|
|
149
|
-
* @param value - The value to check
|
|
150
|
-
* @returns True if the value is a boolean
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
*
|
|
154
|
-
* isBoolean(true); -> true
|
|
155
|
-
* isBoolean(false); -> true
|
|
156
|
-
* isBoolean(0); -> false
|
|
157
|
-
* isBoolean("true"); -> false
|
|
158
|
-
*/
|
|
159
|
-
export declare function isBoolean(value: unknown): value is boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Check if a value is a function.
|
|
162
|
-
*
|
|
163
|
-
* @param value - The value to check
|
|
164
|
-
* @returns True if the value is a function
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
*
|
|
168
|
-
* isFunction(() => {}); -> true
|
|
169
|
-
* isFunction(Math.max); -> true
|
|
170
|
-
* isFunction("function"); -> false
|
|
171
|
-
* isFunction({}); -> false
|
|
172
|
-
*/
|
|
173
|
-
export declare function isFunction<T extends (...args: unknown[]) => unknown>(value: unknown): value is T;
|
|
174
|
-
/**
|
|
175
|
-
* Check if a value is undefined.
|
|
176
|
-
*
|
|
177
|
-
* @param value - The value to check
|
|
178
|
-
* @returns True if the value is undefined
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
*
|
|
182
|
-
* isUndefined(undefined); -> true
|
|
183
|
-
* isUndefined(null); -> false
|
|
184
|
-
* isUndefined(""); -> false
|
|
185
|
-
* isUndefined(0); -> false
|
|
186
|
-
*/
|
|
187
|
-
export declare function isUndefined(value: unknown): value is undefined;
|
|
188
|
-
/**
|
|
189
|
-
* Check if a value is a symbol.
|
|
190
|
-
*
|
|
191
|
-
* @param value - The value to check
|
|
192
|
-
* @returns True if the value is a symbol
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
*
|
|
196
|
-
* isSymbol(Symbol('test')); -> true
|
|
197
|
-
* isSymbol(Symbol.iterator); -> true
|
|
198
|
-
* isSymbol("symbol"); -> false
|
|
199
|
-
* isSymbol({}); -> false
|
|
200
|
-
*/
|
|
201
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
202
|
-
/**
|
|
203
|
-
* Check if a value is null.
|
|
204
|
-
*
|
|
205
|
-
* @param value - The value to check
|
|
206
|
-
* @returns True if the value is null
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
*
|
|
210
|
-
* isNull(null); -> true
|
|
211
|
-
* isNull(undefined); -> false
|
|
212
|
-
* isNull(""); -> false
|
|
213
|
-
* isNull(0); -> false
|
|
214
|
-
*/
|
|
215
|
-
export declare function isNull(value: unknown): value is null;
|
|
216
|
-
/**
|
|
217
|
-
* Check if a value is a Map.
|
|
218
|
-
*
|
|
219
|
-
* @param value - The value to check
|
|
220
|
-
* @returns True if the value is a Map
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
*
|
|
224
|
-
* isMap(new Map()); -> true
|
|
225
|
-
* isMap({}); -> false
|
|
226
|
-
* isMap([]); -> false
|
|
227
|
-
*/
|
|
228
|
-
export declare function isMap<K, V>(value: unknown): value is Map<K, V>;
|
|
229
|
-
/**
|
|
230
|
-
* Check if a value is a Set.
|
|
231
|
-
*
|
|
232
|
-
* @param value - The value to check
|
|
233
|
-
* @returns True if the value is a Set
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
*
|
|
237
|
-
* isSet(new Set()); -> true
|
|
238
|
-
* isSet({}); -> false
|
|
239
|
-
* isSet([]); -> false
|
|
240
|
-
*/
|
|
241
|
-
export declare function isSet<T>(value: unknown): value is Set<T>;
|
|
242
|
-
/**
|
|
243
|
-
* Check if a value is a WeakMap.
|
|
244
|
-
*
|
|
245
|
-
* @param value - The value to check
|
|
246
|
-
* @returns True if the value is a WeakMap
|
|
247
|
-
*/
|
|
248
|
-
export declare function isWeakMap<K extends object, V>(value: unknown): value is WeakMap<K, V>;
|
|
249
|
-
/**
|
|
250
|
-
* Check if a value is a WeakSet.
|
|
251
|
-
*
|
|
252
|
-
* @param value - The value to check
|
|
253
|
-
* @returns True if the value is a WeakSet
|
|
254
|
-
*/
|
|
255
|
-
export declare function isWeakSet<T extends object>(value: unknown): value is WeakSet<T>;
|
|
256
|
-
/**
|
|
257
|
-
* Check if a value is arrayable (has a toArray method).
|
|
258
|
-
*
|
|
259
|
-
* @param value - The value to check
|
|
260
|
-
* @returns True if the value is arrayable
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
*
|
|
264
|
-
* isArrayable({ toArray: () => [1, 2, 3] }); -> true
|
|
265
|
-
* isArrayable([1, 2, 3]); -> false
|
|
266
|
-
* isArrayable("hello"); -> false
|
|
267
|
-
*/
|
|
268
|
-
export declare function toArrayable<T>(value: unknown): value is {
|
|
269
|
-
toArray(): T[];
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Check if a value is jsonable (has a toJSON method).
|
|
273
|
-
*
|
|
274
|
-
* @param value - The value to check
|
|
275
|
-
* @returns True if the value is jsonable
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
*
|
|
279
|
-
* isJsonable({ toJSON: () => ({ a: 1 }) }); -> true
|
|
280
|
-
* isJsonable("hello"); -> false
|
|
281
|
-
*/
|
|
282
|
-
export declare function toJsonable<T>(value: unknown): value is {
|
|
283
|
-
toJson(): T;
|
|
284
|
-
} | {
|
|
285
|
-
toJSON(): T;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Check if a value is json serializable (has a jsonSerialize method).
|
|
289
|
-
*
|
|
290
|
-
* @param value - The value to check
|
|
291
|
-
* @returns True if the value is json serializable
|
|
292
|
-
*
|
|
293
|
-
* @example
|
|
294
|
-
*
|
|
295
|
-
* isJsonSerializable({ jsonSerialize: () => ({ a: 1 }) }); -> true
|
|
296
|
-
* isJsonSerializable("hello"); -> false
|
|
297
|
-
*/
|
|
298
|
-
export declare function toJsonSerializable<T>(value: unknown): value is {
|
|
299
|
-
jsonSerialize(): T;
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* Check if a value is falsy (undefined, null, false, 0, "", empty array/object).
|
|
303
|
-
*
|
|
304
|
-
* @param value - The value to check
|
|
305
|
-
* @returns True if the value is falsy
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
*
|
|
309
|
-
* isFalsy(undefined); -> true
|
|
310
|
-
* isFalsy(null); -> true
|
|
311
|
-
* isFalsy(false); -> true
|
|
312
|
-
* isFalsy(0); -> true
|
|
313
|
-
* isFalsy(""); -> true
|
|
314
|
-
* isFalsy([]); -> true
|
|
315
|
-
* isFalsy({}); -> true
|
|
316
|
-
* isFalsy("hello"); -> false
|
|
317
|
-
* isFalsy([1, 2, 3]); -> false
|
|
318
|
-
* isFalsy({ a: 1 }); -> false
|
|
319
|
-
*/
|
|
320
|
-
export declare function isFalsy<TValue = unknown>(value: TValue): boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Check if a value is truthy (not falsy).
|
|
323
|
-
*
|
|
324
|
-
* @param value - The value to check
|
|
325
|
-
* @returns True if the value is truthy
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
*
|
|
329
|
-
* isTruthy(1); -> true
|
|
330
|
-
* isTruthy("hello"); -> true
|
|
331
|
-
* isTruthy([1, 2, 3]); -> true
|
|
332
|
-
* isTruthy({ a: 1 }); -> true
|
|
333
|
-
* isTruthy(0); -> false
|
|
334
|
-
* isTruthy(""); -> false
|
|
335
|
-
* isTruthy([]); -> false
|
|
336
|
-
* isTruthy({}); -> false
|
|
337
|
-
*/
|
|
338
|
-
export declare function isTruthy(value: unknown): boolean;
|
|
339
|
-
/**
|
|
340
|
-
* Get a more specific type description for debugging purposes.
|
|
341
|
-
* Differentiates between null, arrays, and other types.
|
|
342
|
-
*
|
|
343
|
-
* @param {unknown} v - The value to get the type of.
|
|
344
|
-
* @returns {string} A string describing the type.
|
|
345
|
-
* @example
|
|
346
|
-
* Get specific types
|
|
347
|
-
* typeOf(null); -> "null"
|
|
348
|
-
* typeOf([]); -> "array"
|
|
349
|
-
* typeOf({}); -> "object"
|
|
350
|
-
*/
|
|
351
|
-
export declare function typeOf(v: unknown): string;
|
|
352
|
-
/**
|
|
353
|
-
* Check if a value is a primitive type (null, boolean, number, string, symbol, undefined).
|
|
354
|
-
*
|
|
355
|
-
* @param value - The value to check
|
|
356
|
-
* @returns True if the value is a primitive
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
*
|
|
360
|
-
* isPrimitive(123); -> true
|
|
361
|
-
* isPrimitive("hello"); -> true
|
|
362
|
-
* isPrimitive(null); -> true
|
|
363
|
-
* isPrimitive({}); -> false
|
|
364
|
-
* isPrimitive([]); -> false
|
|
365
|
-
*/
|
|
366
|
-
export declare function isPrimitive(value: unknown): boolean;
|
|
367
|
-
/**
|
|
368
|
-
* Check if a value is a non-primitive type (object, array, function, etc.).
|
|
369
|
-
*
|
|
370
|
-
* @param value - The value to check
|
|
371
|
-
* @returns True if the value is a non-primitive
|
|
372
|
-
*
|
|
373
|
-
* @example
|
|
374
|
-
*
|
|
375
|
-
* isNonPrimitive({}); -> true
|
|
376
|
-
* isNonPrimitive([]); -> true
|
|
377
|
-
* isNonPrimitive(() => {}); -> true
|
|
378
|
-
* isNonPrimitive(123); -> false
|
|
379
|
-
* isNonPrimitive("hello"); -> false
|
|
380
|
-
*/
|
|
381
|
-
export declare function isNonPrimitive(value: unknown): boolean;
|
|
382
|
-
/**
|
|
383
|
-
* Check if a value is a finite number.
|
|
384
|
-
*
|
|
385
|
-
* @param value - The value to check
|
|
386
|
-
* @returns True if the value is a finite number
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
*
|
|
390
|
-
* isFiniteNumber(123); -> true
|
|
391
|
-
* isFiniteNumber(3.14); -> true
|
|
392
|
-
* isFiniteNumber(Infinity); -> false
|
|
393
|
-
* isFiniteNumber(NaN); -> false
|
|
394
|
-
* isFiniteNumber("123"); -> false
|
|
395
|
-
*/
|
|
396
|
-
export declare function isFiniteNumber(value: unknown): value is number;
|
|
397
|
-
/**
|
|
398
|
-
* Convert a value to an array if it's already an array, otherwise return null.
|
|
399
|
-
* Used internally for safe array conversion without coercion.
|
|
400
|
-
*
|
|
401
|
-
* @param {unknown} value - The value to convert.
|
|
402
|
-
* @returns {unknown[] | null} The array if value is an array, null otherwise.
|
|
403
|
-
* @example
|
|
404
|
-
* Convert to array
|
|
405
|
-
* toArray([1, 2, 3]); -> [1, 2, 3]
|
|
406
|
-
* toArray("hello"); -> null
|
|
407
|
-
* toArray({}); -> null
|
|
408
|
-
*/
|
|
409
|
-
export declare function castableToArray<T>(value: unknown): T[] | null;
|
|
410
|
-
/**
|
|
411
|
-
* Helper function to safely compare two unknown values for sorting.
|
|
412
|
-
* Provides stable comparison for objects using JSON serialization.
|
|
413
|
-
*
|
|
414
|
-
* @param a - First value to compare
|
|
415
|
-
* @param b - Second value to compare
|
|
416
|
-
* @returns -1 if a < b, 1 if a > b, 0 if equal
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* compareValues(1, 2); -> -1
|
|
420
|
-
* compareValues('b', 'a'); -> 1
|
|
421
|
-
* compareValues({x: 1}, {x: 1}); -> 0
|
|
422
|
-
*/
|
|
423
|
-
export declare function compareValues(a: unknown, b: unknown): number;
|
|
424
|
-
/**
|
|
425
|
-
* Helper function to resolve a default value (either direct value or lazy function).
|
|
426
|
-
*
|
|
427
|
-
* @param defaultValue - The default value or lazy function
|
|
428
|
-
* @returns The resolved default value
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* resolveDefault('hello'); -> 'hello'
|
|
432
|
-
* resolveDefault(() => 'world'); -> 'world'
|
|
433
|
-
* resolveDefault(undefined); -> null
|
|
434
|
-
*/
|
|
435
|
-
export declare function resolveDefault<D>(defaultValue?: D | (() => D)): D | null;
|
|
436
|
-
/**
|
|
437
|
-
* Helper function to normalize data to an array format.
|
|
438
|
-
* Handles arrays only now.
|
|
439
|
-
*
|
|
440
|
-
* @param data - The data to normalize (array or other)
|
|
441
|
-
* @returns An array representation of the data, or null if not accessible
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* normalizeToArray([1, 2, 3]); -> [1, 2, 3]
|
|
445
|
-
* normalizeToArray('hello'); -> null
|
|
446
|
-
*/
|
|
447
|
-
export declare function normalizeToArray<T>(data: ReadonlyArray<T> | unknown): T[] | null;
|
|
448
|
-
/**
|
|
449
|
-
* Helper function to check if data is accessible (array only).
|
|
450
|
-
*
|
|
451
|
-
* @param data - The data to check
|
|
452
|
-
* @returns True if data is an array
|
|
453
|
-
*
|
|
454
|
-
* @example
|
|
455
|
-
* isAccessibleData([1, 2, 3]); -> true
|
|
456
|
-
* isAccessibleData('hello'); -> false
|
|
457
|
-
*/
|
|
458
|
-
export declare function isAccessibleData(data: unknown): boolean;
|
|
459
|
-
/**
|
|
460
|
-
* Helper function to get normalized values from data.
|
|
461
|
-
* Returns array values or empty array if data is not accessible.
|
|
462
|
-
*
|
|
463
|
-
* @param data - The data to get values from
|
|
464
|
-
* @returns Array of values or empty array
|
|
465
|
-
*
|
|
466
|
-
* @example
|
|
467
|
-
* getAccessibleValues([1, 2, 3]); -> [1, 2, 3]
|
|
468
|
-
* getAccessibleValues('hello'); -> []
|
|
469
|
-
*/
|
|
470
|
-
export declare function getAccessibleValues<T>(data: ReadonlyArray<T> | unknown): T[];
|
|
471
|
-
/**
|
|
472
|
-
* PHP-like loose equality comparison.
|
|
473
|
-
* Mimics PHP's == operator behavior where null, false, 0, '', and [] are considered loosely equal.
|
|
474
|
-
* Also handles deep comparison for arrays and objects.
|
|
475
|
-
*
|
|
476
|
-
* @param a - First value to compare
|
|
477
|
-
* @param b - Second value to compare
|
|
478
|
-
* @returns True if values are loosely equal in PHP-like manner
|
|
479
|
-
*
|
|
480
|
-
* @example
|
|
481
|
-
*
|
|
482
|
-
* looseEqual(null, false); -> true
|
|
483
|
-
* looseEqual(null, 0); -> true
|
|
484
|
-
* looseEqual(null, ''); -> true
|
|
485
|
-
* looseEqual(0, false); -> true
|
|
486
|
-
* looseEqual(1, '1'); -> true
|
|
487
|
-
* looseEqual(['a'], ['a']); -> true
|
|
488
|
-
*/
|
|
489
|
-
export declare function looseEqual(a: unknown, b: unknown): boolean;
|
|
490
|
-
/**
|
|
491
|
-
* PHP-like strict equality comparison (=== operator).
|
|
492
|
-
* Performs strict type checking for primitives but value-based comparison for arrays and objects.
|
|
493
|
-
* NOTE: For class instances (objects with constructors other than Object), uses reference equality.
|
|
494
|
-
*
|
|
495
|
-
* @param a - First value to compare
|
|
496
|
-
* @param b - Second value to compare
|
|
497
|
-
* @returns True if values are strictly equal in PHP-like manner
|
|
498
|
-
*
|
|
499
|
-
* @example
|
|
500
|
-
*
|
|
501
|
-
* strictEqual(1, 1); -> true
|
|
502
|
-
* strictEqual(1, '1'); -> false (different types)
|
|
503
|
-
* strictEqual(['a'], ['a']); -> true (same array content)
|
|
504
|
-
* strictEqual({a: 1}, {a: 1}); -> true (same object content)
|
|
505
|
-
*/
|
|
506
|
-
export declare function strictEqual(a: unknown, b: unknown): boolean;
|
|
507
|
-
/**
|
|
508
|
-
* Figures out if the entry key should be a number or a string.
|
|
509
|
-
*
|
|
510
|
-
* @param value - The entry key value (number, string, or symbol)
|
|
511
|
-
* @returns The entry key as a number if it can be converted, otherwise returns the original value
|
|
512
|
-
*/
|
|
513
|
-
export declare function entriesKeyValue<T extends PropertyKey>(value: T): T extends `${number}` ? number : T;
|
|
514
|
-
/**
|
|
515
|
-
* Check if a key is unsafe for property assignment (prototype pollution).
|
|
516
|
-
* Returns true for `__proto__`, `constructor`, and `prototype`.
|
|
517
|
-
*
|
|
518
|
-
* @param key - The key to check
|
|
519
|
-
* @returns True if the key could cause prototype pollution
|
|
520
|
-
*/
|
|
521
|
-
export declare function isUnsafeKey(key: string): boolean;
|
|
1
|
+
export * from './cast';
|
|
2
|
+
export * from './equality';
|
|
3
|
+
export * from './guards';
|
|
4
|
+
export * from './keys';
|
|
5
|
+
export * from './reflect';
|
|
6
|
+
export * from './string';
|
|
522
7
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|