@tolki/utils 1.1.0 → 1.3.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/dist/cast.d.ts +106 -0
- package/dist/cast.d.ts.map +1 -0
- package/dist/cast.js +46 -0
- package/dist/equality.d.ts +59 -0
- package/dist/equality.d.ts.map +1 -0
- package/dist/equality.js +147 -0
- package/dist/guards.d.ts +429 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +165 -0
- package/dist/index.js +66 -44
- package/dist/keys.d.ts +62 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +40 -0
- package/dist/range.d.ts +23 -0
- package/dist/range.d.ts.map +1 -0
- package/dist/range.js +8 -0
- package/dist/reflect.d.ts +33 -0
- package/dist/reflect.d.ts.map +1 -0
- package/dist/reflect.js +15 -0
- package/dist/sorting.d.ts +20 -0
- package/dist/sorting.d.ts.map +1 -0
- package/dist/sorting.js +18 -0
- package/dist/string.d.ts +27 -0
- package/dist/string.d.ts.map +1 -0
- package/dist/string.js +25 -0
- package/dist/utils.d.ts +8 -540
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +64 -244
- package/package.json +2 -2
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { DataItems } from '@tolki/types';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is an array.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to check
|
|
6
|
+
* @returns True if the value is an array
|
|
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 prototype object: the `prototype` of the constructor it
|
|
51
|
+
* carries as an own property. True for `Object.prototype`, `Array.prototype`,
|
|
52
|
+
* `Function.prototype` and every class prototype.
|
|
53
|
+
*
|
|
54
|
+
* Detects only prototypes carrying an own *function* `constructor`, so
|
|
55
|
+
* `%IteratorPrototype%` and friends -- whose `constructor` is an accessor or
|
|
56
|
+
* absent -- are not detected, and neither is a `Proxy` wrapping a prototype.
|
|
57
|
+
*
|
|
58
|
+
* @param value - The value to check
|
|
59
|
+
* @returns True if the value is some function's prototype object
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
*
|
|
63
|
+
* isPrototypeObject(Object.prototype); -> true
|
|
64
|
+
* isPrototypeObject(Array.prototype); -> true
|
|
65
|
+
* isPrototypeObject({ constructor: Object }); -> false
|
|
66
|
+
* isPrototypeObject({ a: 1 }); -> false
|
|
67
|
+
*/
|
|
68
|
+
export declare function isPrototypeObject(value: unknown): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a value is a string.
|
|
71
|
+
*
|
|
72
|
+
* @param value - The value to check
|
|
73
|
+
* @returns True if the value is a string
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* isString("hello"); -> true
|
|
78
|
+
* isString(123); -> false
|
|
79
|
+
* isString(null); -> false
|
|
80
|
+
*/
|
|
81
|
+
export declare function isString(value: unknown): value is string;
|
|
82
|
+
/**
|
|
83
|
+
* Check if a value is stringable (can be converted to a string).
|
|
84
|
+
*
|
|
85
|
+
* @param value - The value to check
|
|
86
|
+
* @returns True if the value is stringable
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* isStringable("hello"); -> true
|
|
91
|
+
* isStringable(new Stringable('test')); -> true
|
|
92
|
+
* isStringable({ toString: () => "world" }); -> true
|
|
93
|
+
* isStringable(123); -> false
|
|
94
|
+
* isStringable(null); -> false
|
|
95
|
+
*/
|
|
96
|
+
export declare function isStringable(value: unknown): value is string | {
|
|
97
|
+
toString(): string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Check if a value is an object with a toString method.
|
|
101
|
+
*
|
|
102
|
+
* @param value - The value to check
|
|
103
|
+
* @returns True if the value is an object with a toString method
|
|
104
|
+
*/
|
|
105
|
+
export declare function objectToString(value: unknown): value is {
|
|
106
|
+
toString(): string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Check if a value is a number (and not NaN).
|
|
110
|
+
*
|
|
111
|
+
* @param value - The value to check
|
|
112
|
+
* @returns True if the value is a valid number
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
*
|
|
116
|
+
* isNumber(123); -> true
|
|
117
|
+
* isNumber(3.14); -> true
|
|
118
|
+
* isNumber(NaN); -> false
|
|
119
|
+
* isNumber("123"); -> false
|
|
120
|
+
*/
|
|
121
|
+
export declare function isNumber(value: unknown): value is number;
|
|
122
|
+
/**
|
|
123
|
+
* Check if a value is an integer.
|
|
124
|
+
*
|
|
125
|
+
* @param value - The value to check
|
|
126
|
+
* @returns True if the value is an integer
|
|
127
|
+
*/
|
|
128
|
+
export declare function isInteger(value: unknown): value is number;
|
|
129
|
+
/**
|
|
130
|
+
* Check if a value is a float.
|
|
131
|
+
*
|
|
132
|
+
* @param value - The value to check
|
|
133
|
+
* @returns True if the value is a float
|
|
134
|
+
*/
|
|
135
|
+
export declare function isFloat(value: unknown): value is number;
|
|
136
|
+
/**
|
|
137
|
+
* Check if a value is a positive number.
|
|
138
|
+
*
|
|
139
|
+
* @param value - The value to check
|
|
140
|
+
* @returns True if the value is a positive number
|
|
141
|
+
*/
|
|
142
|
+
export declare function isPositiveNumber(value: unknown): value is number;
|
|
143
|
+
/**
|
|
144
|
+
* Check if a value is a negative number.
|
|
145
|
+
*
|
|
146
|
+
* @param value - The value to check
|
|
147
|
+
* @returns True if the value is a negative number
|
|
148
|
+
*/
|
|
149
|
+
export declare function isNegativeNumber(value: unknown): value is number;
|
|
150
|
+
/**
|
|
151
|
+
* Check if a value is a boolean.
|
|
152
|
+
*
|
|
153
|
+
* @param value - The value to check
|
|
154
|
+
* @returns True if the value is a boolean
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
*
|
|
158
|
+
* isBoolean(true); -> true
|
|
159
|
+
* isBoolean(false); -> true
|
|
160
|
+
* isBoolean(0); -> false
|
|
161
|
+
* isBoolean("true"); -> false
|
|
162
|
+
*/
|
|
163
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Check if a value is a function.
|
|
166
|
+
*
|
|
167
|
+
* @param value - The value to check
|
|
168
|
+
* @returns True if the value is a function
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
*
|
|
172
|
+
* isFunction(() => {}); -> true
|
|
173
|
+
* isFunction(Math.max); -> true
|
|
174
|
+
* isFunction("function"); -> false
|
|
175
|
+
* isFunction({}); -> false
|
|
176
|
+
*/
|
|
177
|
+
export declare function isFunction<T extends (...args: unknown[]) => unknown>(value: unknown): value is T;
|
|
178
|
+
/**
|
|
179
|
+
* Check if a value is undefined.
|
|
180
|
+
*
|
|
181
|
+
* @param value - The value to check
|
|
182
|
+
* @returns True if the value is undefined
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
*
|
|
186
|
+
* isUndefined(undefined); -> true
|
|
187
|
+
* isUndefined(null); -> false
|
|
188
|
+
* isUndefined(""); -> false
|
|
189
|
+
* isUndefined(0); -> false
|
|
190
|
+
*/
|
|
191
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Check if a value is a symbol.
|
|
194
|
+
*
|
|
195
|
+
* @param value - The value to check
|
|
196
|
+
* @returns True if the value is a symbol
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
*
|
|
200
|
+
* isSymbol(Symbol('test')); -> true
|
|
201
|
+
* isSymbol(Symbol.iterator); -> true
|
|
202
|
+
* isSymbol("symbol"); -> false
|
|
203
|
+
* isSymbol({}); -> false
|
|
204
|
+
*/
|
|
205
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
|
206
|
+
/**
|
|
207
|
+
* Check if a value is null.
|
|
208
|
+
*
|
|
209
|
+
* @param value - The value to check
|
|
210
|
+
* @returns True if the value is null
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* isNull(null); -> true
|
|
215
|
+
* isNull(undefined); -> false
|
|
216
|
+
* isNull(""); -> false
|
|
217
|
+
* isNull(0); -> false
|
|
218
|
+
*/
|
|
219
|
+
export declare function isNull(value: unknown): value is null;
|
|
220
|
+
/**
|
|
221
|
+
* Check if a value is a Map.
|
|
222
|
+
*
|
|
223
|
+
* @param value - The value to check
|
|
224
|
+
* @returns True if the value is a Map
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
*
|
|
228
|
+
* isMap(new Map()); -> true
|
|
229
|
+
* isMap({}); -> false
|
|
230
|
+
* isMap([]); -> false
|
|
231
|
+
*/
|
|
232
|
+
export declare function isMap<K, V>(value: unknown): value is Map<K, V>;
|
|
233
|
+
/**
|
|
234
|
+
* Check if a value is a Set.
|
|
235
|
+
*
|
|
236
|
+
* @param value - The value to check
|
|
237
|
+
* @returns True if the value is a Set
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
*
|
|
241
|
+
* isSet(new Set()); -> true
|
|
242
|
+
* isSet({}); -> false
|
|
243
|
+
* isSet([]); -> false
|
|
244
|
+
*/
|
|
245
|
+
export declare function isSet<T>(value: unknown): value is Set<T>;
|
|
246
|
+
/**
|
|
247
|
+
* Check if a value is iterable, meaning it implements the iterator protocol.
|
|
248
|
+
*
|
|
249
|
+
* Strings are excluded on purpose because they are treated as scalar values
|
|
250
|
+
* rather than collections, which mirrors how PHP treats strings when a
|
|
251
|
+
* function accepts an `iterable`.
|
|
252
|
+
*
|
|
253
|
+
* @param value - The value to check
|
|
254
|
+
* @returns True if the value can be iterated over with `for...of`
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
*
|
|
258
|
+
* isIterable([1, 2, 3]); -> true
|
|
259
|
+
* isIterable(new Set([1, 2])); -> true
|
|
260
|
+
* isIterable(new Map()); -> true
|
|
261
|
+
* isIterable("abc"); -> false
|
|
262
|
+
* isIterable({ a: 1 }); -> false
|
|
263
|
+
*/
|
|
264
|
+
export declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
265
|
+
/**
|
|
266
|
+
* Check if a value is a WeakMap.
|
|
267
|
+
*
|
|
268
|
+
* @param value - The value to check
|
|
269
|
+
* @returns True if the value is a WeakMap
|
|
270
|
+
*/
|
|
271
|
+
export declare function isWeakMap<K extends object, V>(value: unknown): value is WeakMap<K, V>;
|
|
272
|
+
/**
|
|
273
|
+
* Check if a value is a WeakSet.
|
|
274
|
+
*
|
|
275
|
+
* @param value - The value to check
|
|
276
|
+
* @returns True if the value is a WeakSet
|
|
277
|
+
*/
|
|
278
|
+
export declare function isWeakSet<T extends object>(value: unknown): value is WeakSet<T>;
|
|
279
|
+
/**
|
|
280
|
+
* Check if a value is falsy (undefined, null, false, 0, "", empty array/object).
|
|
281
|
+
*
|
|
282
|
+
* @param value - The value to check
|
|
283
|
+
* @returns True if the value is falsy
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
*
|
|
287
|
+
* isFalsy(undefined); -> true
|
|
288
|
+
* isFalsy(null); -> true
|
|
289
|
+
* isFalsy(false); -> true
|
|
290
|
+
* isFalsy(0); -> true
|
|
291
|
+
* isFalsy(""); -> true
|
|
292
|
+
* isFalsy([]); -> true
|
|
293
|
+
* isFalsy({}); -> true
|
|
294
|
+
* isFalsy("hello"); -> false
|
|
295
|
+
* isFalsy([1, 2, 3]); -> false
|
|
296
|
+
* isFalsy({ a: 1 }); -> false
|
|
297
|
+
*/
|
|
298
|
+
export declare function isFalsy<TValue = unknown>(value: TValue): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Check if a value is truthy (not falsy).
|
|
301
|
+
*
|
|
302
|
+
* @param value - The value to check
|
|
303
|
+
* @returns True if the value is truthy
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
*
|
|
307
|
+
* isTruthy(1); -> true
|
|
308
|
+
* isTruthy("hello"); -> true
|
|
309
|
+
* isTruthy([1, 2, 3]); -> true
|
|
310
|
+
* isTruthy({ a: 1 }); -> true
|
|
311
|
+
* isTruthy(0); -> false
|
|
312
|
+
* isTruthy(""); -> false
|
|
313
|
+
* isTruthy([]); -> false
|
|
314
|
+
* isTruthy({}); -> false
|
|
315
|
+
*/
|
|
316
|
+
export declare function isTruthy(value: unknown): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Determine whether a value is falsy the way PHP's `array_filter()` (no
|
|
319
|
+
* callback) treats it — PHP's own truthiness, not JS's.
|
|
320
|
+
*
|
|
321
|
+
* Drops `false`, `null`/`undefined`, `0`, `""`, `"0"`, and an empty array or
|
|
322
|
+
* plain object; keeps `"00"`, `"0.0"`, and `NaN` (all truthy in PHP).
|
|
323
|
+
*
|
|
324
|
+
* @param value - The value to check
|
|
325
|
+
* @returns True if the value is falsy under PHP's rules
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
*
|
|
329
|
+
* isPhpFalsy("0"); -> true
|
|
330
|
+
* isPhpFalsy("00"); -> false
|
|
331
|
+
*/
|
|
332
|
+
export declare function isPhpFalsy(value: unknown): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Determine whether a value is numeric the way PHP's `is_numeric()` treats
|
|
335
|
+
* it, using PHP's numeric-string grammar rather than JS's `Number()`.
|
|
336
|
+
*
|
|
337
|
+
* `Number("")`, `Number(" ")`, `Number("0x10")`, and `Number("Infinity")` are
|
|
338
|
+
* all numeric to JS but not to PHP.
|
|
339
|
+
*
|
|
340
|
+
* @param value - The value to check
|
|
341
|
+
* @returns True if the value is numeric under PHP's rules
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
*
|
|
345
|
+
* isPhpNumeric("0x10"); -> false
|
|
346
|
+
*/
|
|
347
|
+
export declare function isPhpNumeric(value: unknown): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Check if a value is a primitive type (null, boolean, number, string, symbol, undefined).
|
|
350
|
+
*
|
|
351
|
+
* @param value - The value to check
|
|
352
|
+
* @returns True if the value is a primitive
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
*
|
|
356
|
+
* isPrimitive(123); -> true
|
|
357
|
+
* isPrimitive("hello"); -> true
|
|
358
|
+
* isPrimitive(null); -> true
|
|
359
|
+
* isPrimitive({}); -> false
|
|
360
|
+
* isPrimitive([]); -> false
|
|
361
|
+
*/
|
|
362
|
+
export declare function isPrimitive(value: unknown): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Check if a value is a non-primitive type (object, array, function, etc.).
|
|
365
|
+
*
|
|
366
|
+
* @param value - The value to check
|
|
367
|
+
* @returns True if the value is a non-primitive
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
*
|
|
371
|
+
* isNonPrimitive({}); -> true
|
|
372
|
+
* isNonPrimitive([]); -> true
|
|
373
|
+
* isNonPrimitive(() => {}); -> true
|
|
374
|
+
* isNonPrimitive(123); -> false
|
|
375
|
+
* isNonPrimitive("hello"); -> false
|
|
376
|
+
*/
|
|
377
|
+
export declare function isNonPrimitive(value: unknown): boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Check if a value is a finite number.
|
|
380
|
+
*
|
|
381
|
+
* @param value - The value to check
|
|
382
|
+
* @returns True if the value is a finite number
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
*
|
|
386
|
+
* isFiniteNumber(123); -> true
|
|
387
|
+
* isFiniteNumber(3.14); -> true
|
|
388
|
+
* isFiniteNumber(Infinity); -> false
|
|
389
|
+
* isFiniteNumber(NaN); -> false
|
|
390
|
+
* isFiniteNumber("123"); -> false
|
|
391
|
+
*/
|
|
392
|
+
export declare function isFiniteNumber(value: unknown): value is number;
|
|
393
|
+
/**
|
|
394
|
+
* Helper function to check if data is accessible (array only).
|
|
395
|
+
*
|
|
396
|
+
* @param data - The data to check
|
|
397
|
+
* @returns True if data is an array
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* isAccessibleData([1, 2, 3]); -> true
|
|
401
|
+
* isAccessibleData('hello'); -> false
|
|
402
|
+
*/
|
|
403
|
+
export declare function isAccessibleData(data: unknown): boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Determine whether two values match the way PHP's `array_diff`/`array_intersect`
|
|
406
|
+
* do: `(string) $a === (string) $b`. Only `string`, `boolean`, `null`, and plain
|
|
407
|
+
* finite numbers cast this way; everything else falls back to SameValueZero
|
|
408
|
+
* identity. A high-precision float still casts (JS keeps every digit; PHP's
|
|
409
|
+
* `precision=14` rounds) — a real divergence, not a fallback.
|
|
410
|
+
*
|
|
411
|
+
* @param a - First value to compare
|
|
412
|
+
* @param b - Second value to compare
|
|
413
|
+
* @returns True if the values match under PHP's string-cast comparison, or are identical
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
*
|
|
417
|
+
* phpValueMatch(0, "0"); -> true
|
|
418
|
+
*/
|
|
419
|
+
export declare function phpValueMatch(a: unknown, b: unknown): boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Build a reusable membership test with the same semantics as `phpValueMatch`,
|
|
422
|
+
* without its O(n) rescan per call: cast operands go into a `Set`, so `diff`/
|
|
423
|
+
* `intersect` can test each item in O(1) instead of scanning `others` per item.
|
|
424
|
+
*
|
|
425
|
+
* @param others - The values to test membership against.
|
|
426
|
+
* @returns A predicate that is true when a value matches any of them.
|
|
427
|
+
*/
|
|
428
|
+
export declare function phpValueMatcher(others: readonly unknown[]): (value: unknown) => boolean;
|
|
429
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,IAAI,CAAC,EAAE,CAE5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,GAAG,WAAW,EAC3D,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,GACjC,KAAK,IAAI,MAAM,CAAC,CAA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,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAsChE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAuBlD;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAYpD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAEvD;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAe7D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,SAAS,OAAO,EAAE,GAC3B,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAuB7B"}
|
package/dist/guards.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
function p(t) {
|
|
2
|
+
return Array.isArray(t);
|
|
3
|
+
}
|
|
4
|
+
function b(t) {
|
|
5
|
+
return !i(t) && typeof t == "object" && !p(t);
|
|
6
|
+
}
|
|
7
|
+
function g(t) {
|
|
8
|
+
return typeof t == "object";
|
|
9
|
+
}
|
|
10
|
+
function h(t) {
|
|
11
|
+
return !i(t) && !u(t) && g(t);
|
|
12
|
+
}
|
|
13
|
+
function I(t) {
|
|
14
|
+
if (!h(t) && !c(t))
|
|
15
|
+
return !1;
|
|
16
|
+
const n = Object.getOwnPropertyDescriptor(
|
|
17
|
+
t,
|
|
18
|
+
"constructor"
|
|
19
|
+
)?.value;
|
|
20
|
+
return c(n) && n.prototype === t;
|
|
21
|
+
}
|
|
22
|
+
function o(t) {
|
|
23
|
+
return typeof t == "string";
|
|
24
|
+
}
|
|
25
|
+
function T(t) {
|
|
26
|
+
return !!(o(t) || e(t) || S(t));
|
|
27
|
+
}
|
|
28
|
+
function S(t) {
|
|
29
|
+
return !!(b(t) && c(t.toString));
|
|
30
|
+
}
|
|
31
|
+
function e(t) {
|
|
32
|
+
return typeof t == "number" && !isNaN(t);
|
|
33
|
+
}
|
|
34
|
+
function W(t) {
|
|
35
|
+
return e(t) && Number.isInteger(t);
|
|
36
|
+
}
|
|
37
|
+
function E(t) {
|
|
38
|
+
return e(t) && !Number.isInteger(t);
|
|
39
|
+
}
|
|
40
|
+
function R(t) {
|
|
41
|
+
return e(t) && t >= 0;
|
|
42
|
+
}
|
|
43
|
+
function _(t) {
|
|
44
|
+
return e(t) && t < 0;
|
|
45
|
+
}
|
|
46
|
+
function N(t) {
|
|
47
|
+
return typeof t == "boolean";
|
|
48
|
+
}
|
|
49
|
+
function c(t) {
|
|
50
|
+
return typeof t == "function";
|
|
51
|
+
}
|
|
52
|
+
function u(t) {
|
|
53
|
+
return typeof t > "u";
|
|
54
|
+
}
|
|
55
|
+
function d(t) {
|
|
56
|
+
return typeof t == "symbol";
|
|
57
|
+
}
|
|
58
|
+
function i(t) {
|
|
59
|
+
return t === null;
|
|
60
|
+
}
|
|
61
|
+
function P(t) {
|
|
62
|
+
return t instanceof Map;
|
|
63
|
+
}
|
|
64
|
+
function j(t) {
|
|
65
|
+
return t instanceof Set;
|
|
66
|
+
}
|
|
67
|
+
function w(t) {
|
|
68
|
+
return i(t) || u(t) || o(t) ? !1 : c(
|
|
69
|
+
t[Symbol.iterator]
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function z(t) {
|
|
73
|
+
return t instanceof WeakMap;
|
|
74
|
+
}
|
|
75
|
+
function B(t) {
|
|
76
|
+
return t instanceof WeakSet;
|
|
77
|
+
}
|
|
78
|
+
function A(t) {
|
|
79
|
+
return Number.isNaN(t) ? !0 : e(t) ? t === 0 : u(t) || i(t) ? !0 : N(t) ? t === !1 : o(t) ? t.trim() === "" : P(t) || j(t) ? t.size === 0 : p(t) ? t.length === 0 : b(t) ? Object.keys(t).length === 0 : !1;
|
|
80
|
+
}
|
|
81
|
+
function D(t) {
|
|
82
|
+
return !A(t);
|
|
83
|
+
}
|
|
84
|
+
function U(t) {
|
|
85
|
+
return t === !1 || t === null || u(t) || t === 0 || t === "" || t === "0" ? !0 : p(t) ? t.length === 0 : b(t) ? Object.keys(t).length === 0 : !1;
|
|
86
|
+
}
|
|
87
|
+
const k = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
|
|
88
|
+
function V(t) {
|
|
89
|
+
return typeof t == "number" ? !0 : o(t) ? k.test(t) : !1;
|
|
90
|
+
}
|
|
91
|
+
function O(t) {
|
|
92
|
+
return i(t) || N(t) || e(t) || o(t) || d(t) || u(t);
|
|
93
|
+
}
|
|
94
|
+
function x(t) {
|
|
95
|
+
return !O(t);
|
|
96
|
+
}
|
|
97
|
+
function M(t) {
|
|
98
|
+
return e(t) && Number.isFinite(t);
|
|
99
|
+
}
|
|
100
|
+
function C(t) {
|
|
101
|
+
return Array.isArray(t);
|
|
102
|
+
}
|
|
103
|
+
function y(t) {
|
|
104
|
+
if (o(t))
|
|
105
|
+
return t;
|
|
106
|
+
if (N(t))
|
|
107
|
+
return t ? "1" : "";
|
|
108
|
+
if (i(t))
|
|
109
|
+
return "";
|
|
110
|
+
if (M(t)) {
|
|
111
|
+
const n = String(t);
|
|
112
|
+
return n.includes("e") ? null : n;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function F(t, n) {
|
|
117
|
+
const f = y(t), r = y(n);
|
|
118
|
+
return f !== null && r !== null ? f === r : t === n || typeof t == "number" && typeof n == "number" && Number.isNaN(t) && Number.isNaN(n);
|
|
119
|
+
}
|
|
120
|
+
function G(t) {
|
|
121
|
+
const n = /* @__PURE__ */ new Set(), f = [];
|
|
122
|
+
for (const r of t) {
|
|
123
|
+
const s = y(r);
|
|
124
|
+
i(s) ? f.push(r) : n.add(s);
|
|
125
|
+
}
|
|
126
|
+
return (r) => {
|
|
127
|
+
const s = y(r);
|
|
128
|
+
return i(s) ? f.some((m) => F(r, m)) : n.has(s);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
C as isAccessibleData,
|
|
133
|
+
p as isArray,
|
|
134
|
+
N as isBoolean,
|
|
135
|
+
A as isFalsy,
|
|
136
|
+
M as isFiniteNumber,
|
|
137
|
+
E as isFloat,
|
|
138
|
+
c as isFunction,
|
|
139
|
+
W as isInteger,
|
|
140
|
+
w as isIterable,
|
|
141
|
+
P as isMap,
|
|
142
|
+
_ as isNegativeNumber,
|
|
143
|
+
x as isNonPrimitive,
|
|
144
|
+
i as isNull,
|
|
145
|
+
e as isNumber,
|
|
146
|
+
b as isObject,
|
|
147
|
+
g as isObjectAny,
|
|
148
|
+
U as isPhpFalsy,
|
|
149
|
+
V as isPhpNumeric,
|
|
150
|
+
R as isPositiveNumber,
|
|
151
|
+
O as isPrimitive,
|
|
152
|
+
I as isPrototypeObject,
|
|
153
|
+
j as isSet,
|
|
154
|
+
o as isString,
|
|
155
|
+
T as isStringable,
|
|
156
|
+
d as isSymbol,
|
|
157
|
+
D as isTruthy,
|
|
158
|
+
h as isTruthyObject,
|
|
159
|
+
u as isUndefined,
|
|
160
|
+
z as isWeakMap,
|
|
161
|
+
B as isWeakSet,
|
|
162
|
+
S as objectToString,
|
|
163
|
+
F as phpValueMatch,
|
|
164
|
+
G as phpValueMatcher
|
|
165
|
+
};
|