typetify 0.1.4 → 2.0.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/chunk-IGA3VEZM.mjs +503 -0
- package/dist/chunk-IGA3VEZM.mjs.map +1 -0
- package/dist/chunk-JQAQV75V.js +561 -0
- package/dist/chunk-JQAQV75V.js.map +1 -0
- package/dist/guards/index.d.mts +413 -1
- package/dist/guards/index.d.ts +413 -1
- package/dist/guards/index.js +180 -16
- package/dist/guards/index.mjs +1 -1
- package/dist/index.d.mts +1397 -9
- package/dist/index.d.ts +1397 -9
- package/dist/index.js +1742 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1491 -5
- package/dist/index.mjs.map +1 -1
- package/dist/typed/index.d.mts +2 -2
- package/dist/typed/index.d.ts +2 -2
- package/dist/{types-Db0vauC3.d.mts → types-CPlzx7Jp.d.mts} +1 -1
- package/dist/{types-Db0vauC3.d.ts → types-CPlzx7Jp.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-44Y5JSGU.js +0 -145
- package/dist/chunk-44Y5JSGU.js.map +0 -1
- package/dist/chunk-L3M7LGKL.mjs +0 -128
- package/dist/chunk-L3M7LGKL.mjs.map +0 -1
package/dist/guards/index.d.mts
CHANGED
|
@@ -162,4 +162,416 @@ declare function isEmpty(value: unknown): boolean;
|
|
|
162
162
|
*/
|
|
163
163
|
declare function isNonEmpty(value: unknown): boolean;
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Casts value as an array if it's not one.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* castArray(1) // [1]
|
|
170
|
+
* castArray([1, 2, 3]) // [1, 2, 3]
|
|
171
|
+
* castArray('abc') // ['abc']
|
|
172
|
+
* castArray(null) // [null]
|
|
173
|
+
*/
|
|
174
|
+
declare function castArray<T>(value: T | readonly T[]): T[];
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Like clone but accepts a customizer function.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* cloneWith({ a: 1 }, value => typeof value === 'number' ? value * 2 : undefined)
|
|
181
|
+
* // { a: 2 }
|
|
182
|
+
*/
|
|
183
|
+
declare function cloneWith<T>(value: T, customizer: (value: unknown) => unknown): T;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Like cloneDeep but accepts a customizer function.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* cloneDeepWith({ a: { b: 1 } }, value => typeof value === 'number' ? value * 2 : undefined)
|
|
190
|
+
* // { a: { b: 2 } }
|
|
191
|
+
*/
|
|
192
|
+
declare function cloneDeepWith<T>(value: T, customizer: (value: unknown) => unknown): T;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* const object = { a: 1, b: 2 }
|
|
199
|
+
* conformsTo(object, { a: (n) => n > 0 }) // true
|
|
200
|
+
* conformsTo(object, { b: (n) => n > 5 }) // false
|
|
201
|
+
*/
|
|
202
|
+
declare function conformsTo<T extends Record<string, unknown>>(object: T, source: {
|
|
203
|
+
[K in keyof T]?: (value: T[K]) => boolean;
|
|
204
|
+
}): boolean;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Performs a SameValueZero comparison between two values.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* eq(1, 1) // true
|
|
211
|
+
* eq('a', 'a') // true
|
|
212
|
+
* eq(NaN, NaN) // true
|
|
213
|
+
* eq({}, {}) // false
|
|
214
|
+
*/
|
|
215
|
+
declare function eq(value: unknown, other: unknown): boolean;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Checks if value is greater than other.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* gt(3, 1) // true
|
|
222
|
+
* gt(3, 3) // false
|
|
223
|
+
* gt(1, 3) // false
|
|
224
|
+
*/
|
|
225
|
+
declare function gt(value: number, other: number): boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Checks if value is greater than or equal to other.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* gte(3, 1) // true
|
|
232
|
+
* gte(3, 3) // true
|
|
233
|
+
* gte(1, 3) // false
|
|
234
|
+
*/
|
|
235
|
+
declare function gte(value: number, other: number): boolean;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Checks if value is less than other.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* lt(1, 3) // true
|
|
242
|
+
* lt(3, 3) // false
|
|
243
|
+
* lt(3, 1) // false
|
|
244
|
+
*/
|
|
245
|
+
declare function lt(value: number, other: number): boolean;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Checks if value is less than or equal to other.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* lte(1, 3) // true
|
|
252
|
+
* lte(3, 3) // true
|
|
253
|
+
* lte(3, 1) // false
|
|
254
|
+
*/
|
|
255
|
+
declare function lte(value: number, other: number): boolean;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Checks if value is likely an arguments object.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* function test() { return isArguments(arguments) }
|
|
262
|
+
* test() // true
|
|
263
|
+
* isArguments([1, 2, 3]) // false
|
|
264
|
+
*/
|
|
265
|
+
declare function isArguments(value: unknown): boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Checks if value is an ArrayBuffer.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* isArrayBuffer(new ArrayBuffer(2)) // true
|
|
272
|
+
* isArrayBuffer(new Array(2)) // false
|
|
273
|
+
*/
|
|
274
|
+
declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Checks if value is array-like (has a length property that is a valid array length).
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* isArrayLike([1, 2, 3]) // true
|
|
281
|
+
* isArrayLike('abc') // true
|
|
282
|
+
* isArrayLike({ length: 0 }) // true
|
|
283
|
+
* isArrayLike(() => {}) // false
|
|
284
|
+
*/
|
|
285
|
+
declare function isArrayLike(value: unknown): boolean;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Checks if value is an array-like object.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* isArrayLikeObject([1, 2, 3]) // true
|
|
292
|
+
* isArrayLikeObject({ length: 0 }) // true
|
|
293
|
+
* isArrayLikeObject('abc') // false (string is not an object)
|
|
294
|
+
*/
|
|
295
|
+
declare function isArrayLikeObject(value: unknown): boolean;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Checks if value is a Buffer (Node.js).
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* isBuffer(Buffer.alloc(2)) // true
|
|
302
|
+
* isBuffer(new Uint8Array(2)) // false
|
|
303
|
+
*/
|
|
304
|
+
declare function isBuffer(value: unknown): boolean;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Checks if value is likely a DOM element.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* isElement(document.body) // true
|
|
311
|
+
* isElement('<body>') // false
|
|
312
|
+
*/
|
|
313
|
+
declare function isElement(value: unknown): boolean;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Like isEqual but accepts a customizer function.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* isEqualWith([1, 2], [1, 2], (a, b) => Array.isArray(a) && Array.isArray(b)) // true
|
|
320
|
+
*/
|
|
321
|
+
declare function isEqualWith(value: unknown, other: unknown, customizer: (value: unknown, other: unknown) => boolean | undefined): boolean;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Checks if value is a finite number.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* isFinite(3) // true
|
|
328
|
+
* isFinite(Infinity) // false
|
|
329
|
+
* isFinite('3') // false
|
|
330
|
+
* isFinite(NaN) // false
|
|
331
|
+
*/
|
|
332
|
+
declare function isFinite(value: unknown): value is number;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Checks if value is an integer.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* isInteger(3) // true
|
|
339
|
+
* isInteger(3.0) // true
|
|
340
|
+
* isInteger(3.5) // false
|
|
341
|
+
* isInteger('3') // false
|
|
342
|
+
*/
|
|
343
|
+
declare function isInteger(value: unknown): value is number;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Checks if value is a valid array-like length.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* isLength(3) // true
|
|
350
|
+
* isLength(0) // true
|
|
351
|
+
* isLength(-1) // false
|
|
352
|
+
* isLength(Infinity) // false
|
|
353
|
+
* isLength(Number.MAX_SAFE_INTEGER) // true
|
|
354
|
+
*/
|
|
355
|
+
declare function isLength(value: unknown): value is number;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Checks if value is a Map.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* isMap(new Map()) // true
|
|
362
|
+
* isMap(new WeakMap()) // false
|
|
363
|
+
* isMap({}) // false
|
|
364
|
+
*/
|
|
365
|
+
declare function isMap(value: unknown): value is Map<unknown, unknown>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Performs a partial deep comparison to determine if object contains equivalent property values.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* const object = { a: 1, b: 2 }
|
|
372
|
+
* isMatch(object, { a: 1 }) // true
|
|
373
|
+
* isMatch(object, { b: 2 }) // true
|
|
374
|
+
* isMatch(object, { a: 2 }) // false
|
|
375
|
+
*/
|
|
376
|
+
declare function isMatch(object: Record<string, unknown>, source: Record<string, unknown>): boolean;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Like isMatch but accepts a customizer function.
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* isMatchWith({ a: 1 }, { a: 2 }, (objVal, srcVal) => objVal + 1 === srcVal) // true
|
|
383
|
+
*/
|
|
384
|
+
declare function isMatchWith(object: Record<string, unknown>, source: Record<string, unknown>, customizer: (objValue: unknown, srcValue: unknown, key: string) => boolean | undefined): boolean;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Checks if value is NaN.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* isNaN(NaN) // true
|
|
391
|
+
* isNaN(undefined) // false
|
|
392
|
+
* isNaN('NaN') // false
|
|
393
|
+
*/
|
|
394
|
+
declare function isNaN(value: unknown): boolean;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Checks if value is a native function.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* isNative(Array.prototype.push) // true
|
|
401
|
+
* isNative(() => {}) // false
|
|
402
|
+
*/
|
|
403
|
+
declare function isNative(value: unknown): boolean;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Checks if value is null.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* isNull(null) // true
|
|
410
|
+
* isNull(undefined) // false
|
|
411
|
+
* isNull(0) // false
|
|
412
|
+
*/
|
|
413
|
+
declare function isNull(value: unknown): value is null;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Checks if value is undefined.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* isUndefined(undefined) // true
|
|
420
|
+
* isUndefined(null) // false
|
|
421
|
+
* isUndefined(void 0) // true
|
|
422
|
+
*/
|
|
423
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Checks if value is object-like (not null and typeof is 'object').
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* isObjectLike({}) // true
|
|
430
|
+
* isObjectLike([1, 2, 3]) // true
|
|
431
|
+
* isObjectLike(null) // false
|
|
432
|
+
* isObjectLike(() => {}) // false
|
|
433
|
+
*/
|
|
434
|
+
declare function isObjectLike(value: unknown): boolean;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Checks if value is a RegExp.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* isRegExp(/abc/) // true
|
|
441
|
+
* isRegExp(new RegExp('abc')) // true
|
|
442
|
+
* isRegExp('/abc/') // false
|
|
443
|
+
*/
|
|
444
|
+
declare function isRegExp(value: unknown): value is RegExp;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Checks if value is a safe integer.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* isSafeInteger(3) // true
|
|
451
|
+
* isSafeInteger(Number.MAX_SAFE_INTEGER) // true
|
|
452
|
+
* isSafeInteger(Infinity) // false
|
|
453
|
+
* isSafeInteger('3') // false
|
|
454
|
+
*/
|
|
455
|
+
declare function isSafeInteger(value: unknown): value is number;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Checks if value is a Set.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* isSet(new Set()) // true
|
|
462
|
+
* isSet(new WeakSet()) // false
|
|
463
|
+
* isSet([]) // false
|
|
464
|
+
*/
|
|
465
|
+
declare function isSet(value: unknown): value is Set<unknown>;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Checks if value is a TypedArray.
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* isTypedArray(new Uint8Array()) // true
|
|
472
|
+
* isTypedArray(new Float32Array()) // true
|
|
473
|
+
* isTypedArray([]) // false
|
|
474
|
+
*/
|
|
475
|
+
declare function isTypedArray(value: unknown): boolean;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Checks if value is a WeakMap.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* isWeakMap(new WeakMap()) // true
|
|
482
|
+
* isWeakMap(new Map()) // false
|
|
483
|
+
*/
|
|
484
|
+
declare function isWeakMap(value: unknown): value is WeakMap<object, unknown>;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Checks if value is a WeakSet.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* isWeakSet(new WeakSet()) // true
|
|
491
|
+
* isWeakSet(new Set()) // false
|
|
492
|
+
*/
|
|
493
|
+
declare function isWeakSet(value: unknown): value is WeakSet<object>;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Converts value to an array.
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* toArray({ a: 1, b: 2 }) // [1, 2]
|
|
500
|
+
* toArray('abc') // ['a', 'b', 'c']
|
|
501
|
+
* toArray(1) // []
|
|
502
|
+
* toArray(null) // []
|
|
503
|
+
*/
|
|
504
|
+
declare function toArray<T>(value: unknown): T[];
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Converts value to a finite number.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* toFinite(3.2) // 3.2
|
|
511
|
+
* toFinite(Infinity) // 1.7976931348623157e+308
|
|
512
|
+
* toFinite('3.2') // 3.2
|
|
513
|
+
*/
|
|
514
|
+
declare function toFinite(value: unknown): number;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Converts value to an integer.
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* toInteger(3.2) // 3
|
|
521
|
+
* toInteger('3.2') // 3
|
|
522
|
+
* toInteger(Infinity) // 1.7976931348623157e+308
|
|
523
|
+
*/
|
|
524
|
+
declare function toInteger(value: unknown): number;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Converts value to an integer suitable for use as the length of an array-like object.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* toLength(3.2) // 3
|
|
531
|
+
* toLength(-1) // 0
|
|
532
|
+
* toLength(Infinity) // 4294967295
|
|
533
|
+
*/
|
|
534
|
+
declare function toLength(value: unknown): number;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Converts value to a number.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* toNumber(3.2) // 3.2
|
|
541
|
+
* toNumber('3.2') // 3.2
|
|
542
|
+
* toNumber(Infinity) // Infinity
|
|
543
|
+
* toNumber('abc') // NaN
|
|
544
|
+
*/
|
|
545
|
+
declare function toNumber(value: unknown): number;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Converts value to a plain object flattening inherited enumerable string keyed properties.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* function Foo() { this.b = 2 }
|
|
552
|
+
* Foo.prototype.c = 3
|
|
553
|
+
* toPlainObject(new Foo()) // { b: 2, c: 3 }
|
|
554
|
+
*/
|
|
555
|
+
declare function toPlainObject(value: unknown): Record<string, unknown>;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Converts value to a safe integer.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* toSafeInteger(3.2) // 3
|
|
562
|
+
* toSafeInteger(Infinity) // 9007199254740991
|
|
563
|
+
* toSafeInteger('3.2') // 3
|
|
564
|
+
*/
|
|
565
|
+
declare function toSafeInteger(value: unknown): number;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Converts value to a string. Null and undefined return empty string.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* toString(null) // ''
|
|
572
|
+
* toString(-0) // '-0'
|
|
573
|
+
* toString([1, 2, 3]) // '1,2,3'
|
|
574
|
+
*/
|
|
575
|
+
declare function toString(value: unknown): string;
|
|
576
|
+
|
|
577
|
+
export { castArray, cloneDeepWith, cloneWith, conformsTo, eq, gt, gte, hasKey, hasKeys, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNonEmpty, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPromise, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, lte, toArray, toFinite, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString };
|