is-kit 1.14.3 → 1.15.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 +51 -2
- package/dist/index.d.mts +66 -35
- package/dist/index.d.ts +66 -35
- package/dist/index.js +47 -0
- package/dist/index.mjs +47 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -513,7 +513,46 @@ if (result.valid) {
|
|
|
513
513
|
coercion and does not depend on a transport or schema format such as HTTP or
|
|
514
514
|
OpenAPI.
|
|
515
515
|
|
|
516
|
-
### 11.
|
|
516
|
+
### 11. Validate an exhaustive discriminated union
|
|
517
|
+
|
|
518
|
+
Use `discriminatedUnion<T>()` with `typedStruct` to keep both the branch
|
|
519
|
+
fields and the union coverage aligned with an existing TypeScript type.
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import { discriminatedUnion, isNumber, oneOfValues, typedStruct } from 'is-kit';
|
|
523
|
+
|
|
524
|
+
type Event =
|
|
525
|
+
| { kind: 'click'; x: number; y: number }
|
|
526
|
+
| { kind: 'scroll'; delta: number };
|
|
527
|
+
|
|
528
|
+
const eventUnion = discriminatedUnion<Event>();
|
|
529
|
+
|
|
530
|
+
export const isEvent = eventUnion('kind', ['click', 'scroll'], {
|
|
531
|
+
click: typedStruct<Extract<Event, { kind: 'click' }>>()({
|
|
532
|
+
kind: oneOfValues('click'),
|
|
533
|
+
x: isNumber,
|
|
534
|
+
y: isNumber
|
|
535
|
+
}),
|
|
536
|
+
scroll: typedStruct<Extract<Event, { kind: 'scroll' }>>()({
|
|
537
|
+
kind: oneOfValues('scroll'),
|
|
538
|
+
delta: isNumber
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
The value tuple and object keys must each exactly match the union's
|
|
544
|
+
discriminant values, so adding or removing an `Event` member produces a type
|
|
545
|
+
error until both are updated. The tuple makes finite coverage explicit, so
|
|
546
|
+
broad `string`, `number`, and `symbol` discriminants and infinite
|
|
547
|
+
template-literal types are rejected. Boolean branches use the `true` and
|
|
548
|
+
`false` object keys, which is useful for `Result` types with an `ok` field.
|
|
549
|
+
Discriminants that would coerce to the same object key, such as `1` and `'1'`,
|
|
550
|
+
are rejected because they cannot be represented as separate branches.
|
|
551
|
+
For a `__proto__` discriminant, write the branch as `['__proto__']: guard` (or
|
|
552
|
+
use a null-prototype map); the uncomputed object-literal form changes the
|
|
553
|
+
object's prototype instead of creating a branch entry.
|
|
554
|
+
|
|
555
|
+
### 12. Narrow object keys
|
|
517
556
|
|
|
518
557
|
Use key helpers when the important part of a value is one property.
|
|
519
558
|
|
|
@@ -630,7 +669,7 @@ The library is organized around a few small building blocks:
|
|
|
630
669
|
|
|
631
670
|
- **Primitives**: `isString`, `isNumber`, `isBoolean`, `isInteger`, ...
|
|
632
671
|
- **Composition**: `define`, `and`, `andAll`, `or`, `not`, `oneOf`
|
|
633
|
-
- **Object shapes**: `struct`, `optionalKey`, `hasKey`, `hasKeys`, `narrowKeyTo`, `refineKey`, `refineDefinedKey`, `refineIndex`
|
|
672
|
+
- **Object shapes**: `struct`, `typedStruct`, `discriminatedUnion`, `optionalKey`, `hasKey`, `hasKeys`, `narrowKeyTo`, `refineKey`, `refineDefinedKey`, `refineIndex`
|
|
634
673
|
- **Collections**: `arrayOf`, `nonEmptyArrayOf`, `tupleOf`, `setOf`, `mapOf`, `recordOf`
|
|
635
674
|
- **Literals**: `oneOfValues`, `equals`, `equalsBy`, `equalsKey`
|
|
636
675
|
- **Nullish handling**: `isNil`, `isNotNil`, `nullable`, `nonNull`, `nullish`, `optional`, `required`
|
|
@@ -700,3 +739,13 @@ Requires Node 22.22.0 and pnpm 11.2.2.
|
|
|
700
739
|
See `DEVELOPER.md` for setup details and `CONTRIBUTE.md` for contribution workflow.
|
|
701
740
|
|
|
702
741
|
Pick a guard, compose it, and ship with confidence 🚀
|
|
742
|
+
|
|
743
|
+
## Star History
|
|
744
|
+
|
|
745
|
+
<a href="https://www.star-history.com/?repos=nyaomaru%2Fis-kit&type=date&legend=top-left">
|
|
746
|
+
<picture>
|
|
747
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&theme=dark&legend=top-left" />
|
|
748
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&legend=top-left" />
|
|
749
|
+
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&legend=top-left" />
|
|
750
|
+
</picture>
|
|
751
|
+
</a>
|
package/dist/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@ type Refinement<A, B extends A> = (value: A) => value is B;
|
|
|
12
12
|
/** Predicate that accepts an unknown value and narrows it to `T`. */
|
|
13
13
|
type Predicate<T> = Refinement<unknown, T>;
|
|
14
14
|
/** Readability alias for {@link Predicate}. */
|
|
15
|
-
type Guard<T> = Predicate<T>;
|
|
15
|
+
type Guard$1<T> = Predicate<T>;
|
|
16
16
|
/** Readability alias for {@link Refinement}. */
|
|
17
17
|
type Refine<A, B extends A> = Refinement<A, B>;
|
|
18
18
|
/** Validates the ordered refinement types accepted by `andAll`. */
|
|
@@ -20,7 +20,7 @@ type RefineChain<In, T extends readonly unknown[]> = T extends [] ? [] : T exten
|
|
|
20
20
|
/** Resolves the final narrowed type produced by an ordered refinement chain. */
|
|
21
21
|
type ChainResult<In, T extends readonly unknown[]> = T extends [] ? In : T extends [Refine<In, infer Next>, ...infer R] ? ChainResult<Next, Extract<R, readonly unknown[]>> : never;
|
|
22
22
|
/** Extracts the union of output types from a readonly guard collection. */
|
|
23
|
-
type OutOfGuards<T extends readonly Guard<unknown>[]> = T[number] extends Guard<infer U> ? U : never;
|
|
23
|
+
type OutOfGuards<T extends readonly Guard$1<unknown>[]> = T[number] extends Guard$1<infer U> ? U : never;
|
|
24
24
|
/** Tagged success/failure result containing the value when valid. */
|
|
25
25
|
type ParseResult<T> = {
|
|
26
26
|
valid: true;
|
|
@@ -103,7 +103,7 @@ type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtr
|
|
|
103
103
|
* @param message Optional error message when assertion fails.
|
|
104
104
|
* @returns Nothing when assertion passes; throws an `Error` on failure.
|
|
105
105
|
*/
|
|
106
|
-
export declare function assert<T>(guard: Guard<T>, value: unknown, message?: string): asserts value is T;
|
|
106
|
+
export declare function assert<T>(guard: Guard$1<T>, value: unknown, message?: string): asserts value is T;
|
|
107
107
|
export declare function assert<A, B extends A>(refine: Refine<A, B>, value: A, message?: string): asserts value is B;
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region src/core/define.d.ts
|
|
@@ -127,15 +127,15 @@ export declare function define<T>(fn: (value: unknown) => boolean): Predicate<T>
|
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/core/key-internals.d.ts
|
|
129
129
|
/** Detects whether a type represents more than one possible value. */
|
|
130
|
-
type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
|
|
130
|
+
type IsUnion$1<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
|
|
131
131
|
/** Keeps only one literal property key so one lookup cannot narrow other keys. */
|
|
132
|
-
type SinglePropertyKey<Key extends PropertyKey> = [Key] extends [never] ? never : true extends IsUnion<Key> ? never : {} extends Record<Key, never> ? never : Key;
|
|
132
|
+
type SinglePropertyKey<Key extends PropertyKey> = [Key] extends [never] ? never : true extends IsUnion$1<Key> ? never : {} extends Record<Key, never> ? never : Key;
|
|
133
133
|
/** Applies the singleton-key constraint to every member of a key tuple. */
|
|
134
134
|
type SinglePropertyKeys<Keys extends readonly PropertyKey[]> = { [Index in keyof Keys]: Keys[Index] & SinglePropertyKey<Keys[Index]>; };
|
|
135
135
|
/** Narrows one concrete key, or only object-ness for a multi-value key domain. */
|
|
136
136
|
type KeyPresence<Key extends PropertyKey> = [SinglePropertyKey<Key>] extends [never] ? object : Record<Key, unknown>;
|
|
137
137
|
/** Narrows concrete key arguments, or only object-ness when any may vary. */
|
|
138
|
-
type KeyPresences<Keys extends readonly PropertyKey[]> = true extends IsUnion<Keys> ? object : [Keys] extends [SinglePropertyKeys<Keys>] ? Record<Keys[number], unknown> : object;
|
|
138
|
+
type KeyPresences<Keys extends readonly PropertyKey[]> = true extends IsUnion$1<Keys> ? object : [Keys] extends [SinglePropertyKeys<Keys>] ? Record<Keys[number], unknown> : object;
|
|
139
139
|
/** Keeps only one non-negative integer literal that identifies an array index. */
|
|
140
140
|
type ArrayIndex<Index extends number> = SinglePropertyKey<Index> extends never ? never : `${Index}` extends `-${string}` ? never : `${Index}` extends `${bigint}` ? Index : never;
|
|
141
141
|
//#endregion
|
|
@@ -199,7 +199,7 @@ export declare function hasKeys<const KS extends readonly [PropertyKey, ...Prope
|
|
|
199
199
|
* narrows a singleton `key` to that literal. Multi-value key domains preserve
|
|
200
200
|
* only the base guard's type.
|
|
201
201
|
*/
|
|
202
|
-
export declare function narrowKeyTo<A, const K extends keyof A & PropertyKey>(guard: Guard<A>, key: K): <const T extends A[K]>(target: T) => NarrowKeyPredicate<A, K, T>;
|
|
202
|
+
export declare function narrowKeyTo<A, const K extends keyof A & PropertyKey>(guard: Guard$1<A>, key: K): <const T extends A[K]>(target: T) => NarrowKeyPredicate<A, K, T>;
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/core/property-refinement.d.ts
|
|
205
205
|
/**
|
|
@@ -265,7 +265,7 @@ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [...unkn
|
|
|
265
265
|
* );
|
|
266
266
|
* @see andAll
|
|
267
267
|
*/
|
|
268
|
-
export declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
|
|
268
|
+
export declare function and<A, B extends A>(precondition: Guard$1<A>, condition: Refine<A, B>): Predicate<B>;
|
|
269
269
|
export declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
|
|
270
270
|
/**
|
|
271
271
|
* Chains refinements while preserving the precondition's input domain.
|
|
@@ -280,10 +280,10 @@ export declare function and<A, B extends A, C extends B>(precondition: Refinemen
|
|
|
280
280
|
* const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
|
|
281
281
|
* @see and
|
|
282
282
|
*/
|
|
283
|
-
export declare function andAll<A>(precondition: Guard<A>): Guard<A>;
|
|
284
|
-
export declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
|
|
285
|
-
export declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
|
|
286
|
-
export declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
|
|
283
|
+
export declare function andAll<A>(precondition: Guard$1<A>): Guard$1<A>;
|
|
284
|
+
export declare function andAll<A, B extends A>(precondition: Guard$1<A>, step1: Refine<A, B>): Guard$1<B>;
|
|
285
|
+
export declare function andAll<A, B extends A, C extends B>(precondition: Guard$1<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard$1<C>;
|
|
286
|
+
export declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard$1<A>, ...steps: Chain & RefineChain<A, Chain>): Guard$1<ChainResult<A, Chain>>;
|
|
287
287
|
export declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
|
|
288
288
|
export declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
|
|
289
289
|
export declare function andAll<A, B extends A, C extends B, D extends C>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>, step2: Refine<NoInfer<C>, D>): Refinement<A, D>;
|
|
@@ -302,7 +302,7 @@ export declare function andAll<A, B extends A>(precondition: Refinement<A, B>, .
|
|
|
302
302
|
* const isId = or(isString, isNumber);
|
|
303
303
|
* @see oneOf
|
|
304
304
|
*/
|
|
305
|
-
export declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
|
|
305
|
+
export declare function or<P extends readonly Guard$1<unknown>[]>(...guards: P): Guard$1<OutOfGuards<P>>;
|
|
306
306
|
export declare function or<A, B extends A, Rest extends readonly Refinement<A, A>[]>(first: Refinement<A, B>, ...rest: Rest): Refinement<A, B | GuardedOf<Rest[number]>>;
|
|
307
307
|
/**
|
|
308
308
|
* Adapts a guard so it can be used as a refinement within a known supertype.
|
|
@@ -310,7 +310,7 @@ export declare function or<A, B extends A, Rest extends readonly Refinement<A, A
|
|
|
310
310
|
* @returns Function that converts a `Guard<T>` into a `Refine<A, T>` when `T extends A`.
|
|
311
311
|
* @see and
|
|
312
312
|
*/
|
|
313
|
-
export declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
|
|
313
|
+
export declare function guardIn<A>(): <T extends A>(guard: Guard$1<T>) => Refine<A, T>;
|
|
314
314
|
/**
|
|
315
315
|
* Logical negation of a guard/refinement.
|
|
316
316
|
* Use this when a negated predicate should be named and reused.
|
|
@@ -320,7 +320,7 @@ export declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A
|
|
|
320
320
|
* @example
|
|
321
321
|
* const isPresent = not(isNil);
|
|
322
322
|
*/
|
|
323
|
-
export declare function not<A, T>(guard: Guard<T>): Refine<A, Exclude<A, Extract<A, T>>>;
|
|
323
|
+
export declare function not<A, T>(guard: Guard$1<T>): Refine<A, Exclude<A, Extract<A, T>>>;
|
|
324
324
|
export declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A, B>>;
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region src/core/nullish.d.ts
|
|
@@ -335,7 +335,7 @@ export declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exc
|
|
|
335
335
|
* const isNullableString = nullable(isString);
|
|
336
336
|
* @see nullish
|
|
337
337
|
*/
|
|
338
|
-
export declare function nullable<T>(guard: Guard<T>): Guard<T | null>;
|
|
338
|
+
export declare function nullable<T>(guard: Guard$1<T>): Guard$1<T | null>;
|
|
339
339
|
export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
|
|
340
340
|
/**
|
|
341
341
|
* Excludes `null` from the accepted values.
|
|
@@ -345,7 +345,7 @@ export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
345
345
|
* @example
|
|
346
346
|
* const isNonNullString = nonNull(nullable(isString));
|
|
347
347
|
*/
|
|
348
|
-
export declare function nonNull<T>(guard: Guard<T>): Guard<Exclude<T, null>>;
|
|
348
|
+
export declare function nonNull<T>(guard: Guard$1<T>): Guard$1<Exclude<T, null>>;
|
|
349
349
|
export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A, null>, Exclude<B, null>>;
|
|
350
350
|
/**
|
|
351
351
|
* Allows `null` or `undefined` in addition to values accepted by the guard.
|
|
@@ -358,7 +358,7 @@ export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Ex
|
|
|
358
358
|
* const isNullishString = nullish(isString);
|
|
359
359
|
* @see isNil
|
|
360
360
|
*/
|
|
361
|
-
export declare function nullish<T>(guard: Guard<T>): Guard<T | null | undefined>;
|
|
361
|
+
export declare function nullish<T>(guard: Guard$1<T>): Guard$1<T | null | undefined>;
|
|
362
362
|
export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null | undefined, B | null | undefined>;
|
|
363
363
|
/**
|
|
364
364
|
* Allows `undefined` in addition to values accepted by the guard.
|
|
@@ -370,7 +370,7 @@ export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
370
370
|
* @example
|
|
371
371
|
* const isOptionalString = optional(isString);
|
|
372
372
|
*/
|
|
373
|
-
export declare function optional<T>(guard: Guard<T>): Guard<T | undefined>;
|
|
373
|
+
export declare function optional<T>(guard: Guard$1<T>): Guard$1<T | undefined>;
|
|
374
374
|
export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
|
|
375
375
|
/**
|
|
376
376
|
* Requires a value to be present (excludes `undefined`).
|
|
@@ -380,7 +380,7 @@ export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
380
380
|
* @example
|
|
381
381
|
* const isRequiredString = required(optional(isString));
|
|
382
382
|
*/
|
|
383
|
-
export declare function required<T>(guard: Guard<T | undefined>): Guard<T>;
|
|
383
|
+
export declare function required<T>(guard: Guard$1<T | undefined>): Guard$1<T>;
|
|
384
384
|
export declare function required<A, B extends A>(refine: Refine<A | undefined, B | undefined>): Refine<A, B>;
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/core/parse.d.ts
|
|
@@ -391,7 +391,7 @@ export declare function required<A, B extends A>(refine: Refine<A | undefined, B
|
|
|
391
391
|
* @param value Value to check.
|
|
392
392
|
* @returns `{ valid: true, value }` when the guard passes; `{ valid: false }` otherwise.
|
|
393
393
|
*/
|
|
394
|
-
export declare function safeParse<T>(guard: Guard<T>, value: unknown): ParseResult<T>;
|
|
394
|
+
export declare function safeParse<T>(guard: Guard$1<T>, value: unknown): ParseResult<T>;
|
|
395
395
|
export declare function safeParse<A, B extends A>(refine: Refine<A, B>, value: A): ParseResult<B>;
|
|
396
396
|
export declare function safeParse(fn: (value: unknown) => boolean, value: unknown): ParseResult<unknown>;
|
|
397
397
|
/**
|
|
@@ -400,7 +400,7 @@ export declare function safeParse(fn: (value: unknown) => boolean, value: unknow
|
|
|
400
400
|
* @param guard Guard/refinement to evaluate.
|
|
401
401
|
* @returns Function that takes a value and returns the `ParseResult`.
|
|
402
402
|
*/
|
|
403
|
-
export declare function safeParseWith<T>(guard: Guard<T>): (value: unknown) => ParseResult<T>;
|
|
403
|
+
export declare function safeParseWith<T>(guard: Guard$1<T>): (value: unknown) => ParseResult<T>;
|
|
404
404
|
export declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
|
|
405
405
|
/**
|
|
406
406
|
* Decodes JSON text and validates the decoded value without coercion.
|
|
@@ -565,7 +565,7 @@ export declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
|
|
|
565
565
|
*
|
|
566
566
|
* @returns Predicate narrowing to `Primitive`.
|
|
567
567
|
*/
|
|
568
|
-
export declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
568
|
+
export declare const isPrimitive: Guard$1<string | number | bigint | boolean | symbol | null | undefined>;
|
|
569
569
|
//#endregion
|
|
570
570
|
//#region src/core/object.d.ts
|
|
571
571
|
type AnyFunction = (...args: never[]) => unknown;
|
|
@@ -604,31 +604,31 @@ export declare const isDate: Predicate<Date>;
|
|
|
604
604
|
*
|
|
605
605
|
* @returns Predicate narrowing to `RegExp`.
|
|
606
606
|
*/
|
|
607
|
-
export declare const isRegExp: Guard<RegExp>;
|
|
607
|
+
export declare const isRegExp: Guard$1<RegExp>;
|
|
608
608
|
/**
|
|
609
609
|
* Checks whether a value is a `Map`.
|
|
610
610
|
*
|
|
611
611
|
* @returns Predicate narrowing to `Map<unknown, unknown>`.
|
|
612
612
|
*/
|
|
613
|
-
export declare const isMap: Guard<Map<unknown, unknown>>;
|
|
613
|
+
export declare const isMap: Guard$1<Map<unknown, unknown>>;
|
|
614
614
|
/**
|
|
615
615
|
* Checks whether a value is a `Set`.
|
|
616
616
|
*
|
|
617
617
|
* @returns Predicate narrowing to `Set<unknown>`.
|
|
618
618
|
*/
|
|
619
|
-
export declare const isSet: Guard<Set<unknown>>;
|
|
619
|
+
export declare const isSet: Guard$1<Set<unknown>>;
|
|
620
620
|
/**
|
|
621
621
|
* Checks whether a value is a `WeakMap`.
|
|
622
622
|
*
|
|
623
623
|
* @returns Predicate narrowing to `WeakMap<object, unknown>`.
|
|
624
624
|
*/
|
|
625
|
-
export declare const isWeakMap: Guard<WeakMap<object, unknown>>;
|
|
625
|
+
export declare const isWeakMap: Guard$1<WeakMap<object, unknown>>;
|
|
626
626
|
/**
|
|
627
627
|
* Checks whether a value is a `WeakSet`.
|
|
628
628
|
*
|
|
629
629
|
* @returns Predicate narrowing to `WeakSet<object>`.
|
|
630
630
|
*/
|
|
631
|
-
export declare const isWeakSet: Guard<WeakSet<object>>;
|
|
631
|
+
export declare const isWeakSet: Guard$1<WeakSet<object>>;
|
|
632
632
|
/**
|
|
633
633
|
* Checks whether a value is promise-like (has a `then` function).
|
|
634
634
|
*
|
|
@@ -652,13 +652,13 @@ export declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
|
|
|
652
652
|
*
|
|
653
653
|
* @returns Predicate narrowing to `ArrayBuffer`.
|
|
654
654
|
*/
|
|
655
|
-
export declare const isArrayBuffer: Guard<ArrayBuffer>;
|
|
655
|
+
export declare const isArrayBuffer: Guard$1<ArrayBuffer>;
|
|
656
656
|
/**
|
|
657
657
|
* Checks whether a value is a `DataView`.
|
|
658
658
|
*
|
|
659
659
|
* @returns Predicate narrowing to `DataView`.
|
|
660
660
|
*/
|
|
661
|
-
export declare const isDataView: Guard<DataView<ArrayBufferLike>>;
|
|
661
|
+
export declare const isDataView: Guard$1<DataView<ArrayBufferLike>>;
|
|
662
662
|
/**
|
|
663
663
|
* Checks whether a value is a typed array view (any `ArrayBufferView` except DataView).
|
|
664
664
|
*
|
|
@@ -676,26 +676,26 @@ export declare const isError: Predicate<Error>;
|
|
|
676
676
|
*
|
|
677
677
|
* @returns Predicate narrowing to `URL` when supported; otherwise always false.
|
|
678
678
|
*/
|
|
679
|
-
export declare const isURL: Guard<URL>;
|
|
679
|
+
export declare const isURL: Guard$1<URL>;
|
|
680
680
|
/**
|
|
681
681
|
* Checks whether a value is a `Blob` (in environments with Blob available).
|
|
682
682
|
*
|
|
683
683
|
* @returns Predicate narrowing to `Blob` when supported; otherwise always false.
|
|
684
684
|
*/
|
|
685
|
-
export declare const isBlob: Guard<Blob>;
|
|
685
|
+
export declare const isBlob: Guard$1<Blob>;
|
|
686
686
|
/**
|
|
687
687
|
* Checks whether a value is a `File` (in environments with File available).
|
|
688
688
|
*
|
|
689
689
|
* @returns Predicate narrowing to `File` when supported; otherwise always false.
|
|
690
690
|
*/
|
|
691
|
-
export declare const isFile: Guard<File>;
|
|
691
|
+
export declare const isFile: Guard$1<File>;
|
|
692
692
|
/**
|
|
693
693
|
* Creates a guard that checks whether a value is an instance of `constructor`.
|
|
694
694
|
*
|
|
695
695
|
* @param constructor Constructor used as the right-hand side of `instanceof`.
|
|
696
696
|
* @returns Predicate narrowing to `InstanceType<C>`.
|
|
697
697
|
*/
|
|
698
|
-
export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard<InstanceType<C>>;
|
|
698
|
+
export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard$1<InstanceType<C>>;
|
|
699
699
|
//#endregion
|
|
700
700
|
//#region src/core/combinators/array.d.ts
|
|
701
701
|
/**
|
|
@@ -713,6 +713,37 @@ export declare function arrayOf<F extends Predicate<unknown>>(elementGuard: F):
|
|
|
713
713
|
*/
|
|
714
714
|
export declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
|
|
715
715
|
//#endregion
|
|
716
|
+
//#region src/core/combinators/discriminated-union.d.ts
|
|
717
|
+
type DiscriminantValue = PropertyKey | boolean;
|
|
718
|
+
type IsFixedDiscriminantValue<Value extends DiscriminantValue> = Value extends unknown ? Value extends boolean ? true : Value extends PropertyKey ? {} extends Record<Value, unknown> ? false : true : false : never;
|
|
719
|
+
type IsFiniteDiscriminantValue<Values extends DiscriminantValue> = false extends IsFixedDiscriminantValue<Values> ? false : true;
|
|
720
|
+
type DiscriminantKey<T extends object> = { [K in keyof T]-?: [T] extends [Record<K, DiscriminantValue>] ? IsFiniteDiscriminantValue<T[K] & DiscriminantValue> extends true ? K : never : never; }[keyof T];
|
|
721
|
+
type DiscriminantValues<T extends object, K extends DiscriminantKey<T>> = T extends Record<K, infer Value> ? Value & DiscriminantValue : never;
|
|
722
|
+
type DiscriminantMapKey<Value extends DiscriminantValue> = Value extends boolean ? `${Value}` : Value;
|
|
723
|
+
type DiscriminantRuntimeKey<Value extends DiscriminantValue> = Value extends symbol ? Value : Value extends string | number | boolean ? `${Value}` : never;
|
|
724
|
+
type CollidingDiscriminantValues<Values extends DiscriminantValue, AllValues extends DiscriminantValue = Values> = Values extends unknown ? DiscriminantRuntimeKey<Values> extends DiscriminantRuntimeKey<Exclude<AllValues, Values>> ? Values : never : never;
|
|
725
|
+
type NonCollidingDiscriminants<T extends object, K extends DiscriminantKey<T>> = [CollidingDiscriminantValues<DiscriminantValues<T, K>>] extends [never] ? unknown : never;
|
|
726
|
+
type IsUnion<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
|
|
727
|
+
type HasUnionElement<Values extends readonly unknown[]> = Values extends readonly [infer Head, ...infer Tail extends readonly unknown[]] ? true extends IsUnion<Head> ? true : HasUnionElement<Tail> : false;
|
|
728
|
+
type ExactDiscriminantValues<T extends object, K extends DiscriminantKey<T>, Values extends readonly DiscriminantValue[]> = Values extends unknown ? number extends Values['length'] ? never : HasUnionElement<Values> extends true ? never : [DiscriminantValues<T, K>] extends [Values[number]] ? [Values[number]] extends [DiscriminantValues<T, K>] ? unknown : never : never : never;
|
|
729
|
+
type MatchingDiscriminantMember<T extends object, K extends DiscriminantKey<T>, Value extends DiscriminantValue> = T extends Record<K, DiscriminantValue> ? Value extends T[K] ? T : never : never;
|
|
730
|
+
type DiscriminatedUnionGuardMap<T extends object, K extends DiscriminantKey<T>, Values extends DiscriminantValue> = { readonly [Value in Values as DiscriminantMapKey<Value>]: Predicate<MatchingDiscriminantMember<T, K, Value>>; };
|
|
731
|
+
type InvalidGuardDiscriminantValues<K extends PropertyKey, Values extends DiscriminantValue, G extends object> = { [Value in Values as DiscriminantMapKey<Value>]: G extends Record<DiscriminantMapKey<Value>, infer Guard> ? GuardedOf<Guard> extends Record<K, DiscriminantValue> ? Value extends GuardedOf<Guard>[K] ? never : Value : Value : Value; }[DiscriminantMapKey<Values>];
|
|
732
|
+
type GuardsMatchDiscriminantValues<K extends PropertyKey, Values extends DiscriminantValue, G extends object> = [InvalidGuardDiscriminantValues<K, Values, G>] extends [never] ? unknown : never;
|
|
733
|
+
/**
|
|
734
|
+
* Creates an exhaustive guard for a union whose members share a literal discriminant.
|
|
735
|
+
* A tuple of every discriminant value keeps finite coverage explicit at runtime
|
|
736
|
+
* and compile time. Values that coerce to the same object key, such as `1` and
|
|
737
|
+
* `'1'`, are rejected.
|
|
738
|
+
* Use `['__proto__']` for that literal discriminant so it becomes an own map key.
|
|
739
|
+
*
|
|
740
|
+
* @param discriminant Required property that identifies each union member.
|
|
741
|
+
* @param values Finite tuple containing every discriminant value.
|
|
742
|
+
* @param guards Branch guards keyed by the discriminant values.
|
|
743
|
+
* @returns Predicate narrowing to the union accepted by the branch guards.
|
|
744
|
+
*/
|
|
745
|
+
export declare function discriminatedUnion<T extends object>(): <const K extends DiscriminantKey<T>, const Values extends readonly DiscriminantValue[], const G extends DiscriminatedUnionGuardMap<T, K, Values[number]>>(discriminant: K, values: Values & ExactDiscriminantValues<T, K, Values>, guards: NoExtraKeys<G, DiscriminatedUnionGuardMap<T, K, Values[number]>> & NonCollidingDiscriminants<T, K> & GuardsMatchDiscriminantValues<K, Values[number], G>) => Predicate<GuardedOf<G[keyof G]>>;
|
|
746
|
+
//#endregion
|
|
716
747
|
//#region src/core/combinators/map.d.ts
|
|
717
748
|
/**
|
|
718
749
|
* Validates a map where every key and value satisfies the provided guards.
|
|
@@ -880,4 +911,4 @@ export declare const everyOwnEnumerableEntry: (values: Record<string, unknown>,
|
|
|
880
911
|
*/
|
|
881
912
|
export declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
882
913
|
//#endregion
|
|
883
|
-
export type { ChainResult, Guard, GuardedOf, GuardedWithin, InferSchema, NoExtraKeys, OptionalObjectKeys, OptionalSchemaField, OutOfGuards, ParseResult, Predicate, Primitive, Refine, RefineChain, Refinement, RequiredObjectKeys, Schema, SchemaField, StructOptions, TypedStructFields, TypedStructShape };
|
|
914
|
+
export type { ChainResult, Guard$1 as Guard, GuardedOf, GuardedWithin, InferSchema, NoExtraKeys, OptionalObjectKeys, OptionalSchemaField, OutOfGuards, ParseResult, Predicate, Primitive, Refine, RefineChain, Refinement, RequiredObjectKeys, Schema, SchemaField, StructOptions, TypedStructFields, TypedStructShape };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type Refinement<A, B extends A> = (value: A) => value is B;
|
|
|
12
12
|
/** Predicate that accepts an unknown value and narrows it to `T`. */
|
|
13
13
|
type Predicate<T> = Refinement<unknown, T>;
|
|
14
14
|
/** Readability alias for {@link Predicate}. */
|
|
15
|
-
type Guard<T> = Predicate<T>;
|
|
15
|
+
type Guard$1<T> = Predicate<T>;
|
|
16
16
|
/** Readability alias for {@link Refinement}. */
|
|
17
17
|
type Refine<A, B extends A> = Refinement<A, B>;
|
|
18
18
|
/** Validates the ordered refinement types accepted by `andAll`. */
|
|
@@ -20,7 +20,7 @@ type RefineChain<In, T extends readonly unknown[]> = T extends [] ? [] : T exten
|
|
|
20
20
|
/** Resolves the final narrowed type produced by an ordered refinement chain. */
|
|
21
21
|
type ChainResult<In, T extends readonly unknown[]> = T extends [] ? In : T extends [Refine<In, infer Next>, ...infer R] ? ChainResult<Next, Extract<R, readonly unknown[]>> : never;
|
|
22
22
|
/** Extracts the union of output types from a readonly guard collection. */
|
|
23
|
-
type OutOfGuards<T extends readonly Guard<unknown>[]> = T[number] extends Guard<infer U> ? U : never;
|
|
23
|
+
type OutOfGuards<T extends readonly Guard$1<unknown>[]> = T[number] extends Guard$1<infer U> ? U : never;
|
|
24
24
|
/** Tagged success/failure result containing the value when valid. */
|
|
25
25
|
type ParseResult<T> = {
|
|
26
26
|
valid: true;
|
|
@@ -103,7 +103,7 @@ type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtr
|
|
|
103
103
|
* @param message Optional error message when assertion fails.
|
|
104
104
|
* @returns Nothing when assertion passes; throws an `Error` on failure.
|
|
105
105
|
*/
|
|
106
|
-
export declare function assert<T>(guard: Guard<T>, value: unknown, message?: string): asserts value is T;
|
|
106
|
+
export declare function assert<T>(guard: Guard$1<T>, value: unknown, message?: string): asserts value is T;
|
|
107
107
|
export declare function assert<A, B extends A>(refine: Refine<A, B>, value: A, message?: string): asserts value is B;
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region src/core/define.d.ts
|
|
@@ -127,15 +127,15 @@ export declare function define<T>(fn: (value: unknown) => boolean): Predicate<T>
|
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/core/key-internals.d.ts
|
|
129
129
|
/** Detects whether a type represents more than one possible value. */
|
|
130
|
-
type IsUnion<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
|
|
130
|
+
type IsUnion$1<Value, Whole = Value> = Value extends Whole ? [Whole] extends [Value] ? false : true : never;
|
|
131
131
|
/** Keeps only one literal property key so one lookup cannot narrow other keys. */
|
|
132
|
-
type SinglePropertyKey<Key extends PropertyKey> = [Key] extends [never] ? never : true extends IsUnion<Key> ? never : {} extends Record<Key, never> ? never : Key;
|
|
132
|
+
type SinglePropertyKey<Key extends PropertyKey> = [Key] extends [never] ? never : true extends IsUnion$1<Key> ? never : {} extends Record<Key, never> ? never : Key;
|
|
133
133
|
/** Applies the singleton-key constraint to every member of a key tuple. */
|
|
134
134
|
type SinglePropertyKeys<Keys extends readonly PropertyKey[]> = { [Index in keyof Keys]: Keys[Index] & SinglePropertyKey<Keys[Index]>; };
|
|
135
135
|
/** Narrows one concrete key, or only object-ness for a multi-value key domain. */
|
|
136
136
|
type KeyPresence<Key extends PropertyKey> = [SinglePropertyKey<Key>] extends [never] ? object : Record<Key, unknown>;
|
|
137
137
|
/** Narrows concrete key arguments, or only object-ness when any may vary. */
|
|
138
|
-
type KeyPresences<Keys extends readonly PropertyKey[]> = true extends IsUnion<Keys> ? object : [Keys] extends [SinglePropertyKeys<Keys>] ? Record<Keys[number], unknown> : object;
|
|
138
|
+
type KeyPresences<Keys extends readonly PropertyKey[]> = true extends IsUnion$1<Keys> ? object : [Keys] extends [SinglePropertyKeys<Keys>] ? Record<Keys[number], unknown> : object;
|
|
139
139
|
/** Keeps only one non-negative integer literal that identifies an array index. */
|
|
140
140
|
type ArrayIndex<Index extends number> = SinglePropertyKey<Index> extends never ? never : `${Index}` extends `-${string}` ? never : `${Index}` extends `${bigint}` ? Index : never;
|
|
141
141
|
//#endregion
|
|
@@ -199,7 +199,7 @@ export declare function hasKeys<const KS extends readonly [PropertyKey, ...Prope
|
|
|
199
199
|
* narrows a singleton `key` to that literal. Multi-value key domains preserve
|
|
200
200
|
* only the base guard's type.
|
|
201
201
|
*/
|
|
202
|
-
export declare function narrowKeyTo<A, const K extends keyof A & PropertyKey>(guard: Guard<A>, key: K): <const T extends A[K]>(target: T) => NarrowKeyPredicate<A, K, T>;
|
|
202
|
+
export declare function narrowKeyTo<A, const K extends keyof A & PropertyKey>(guard: Guard$1<A>, key: K): <const T extends A[K]>(target: T) => NarrowKeyPredicate<A, K, T>;
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/core/property-refinement.d.ts
|
|
205
205
|
/**
|
|
@@ -265,7 +265,7 @@ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [...unkn
|
|
|
265
265
|
* );
|
|
266
266
|
* @see andAll
|
|
267
267
|
*/
|
|
268
|
-
export declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
|
|
268
|
+
export declare function and<A, B extends A>(precondition: Guard$1<A>, condition: Refine<A, B>): Predicate<B>;
|
|
269
269
|
export declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
|
|
270
270
|
/**
|
|
271
271
|
* Chains refinements while preserving the precondition's input domain.
|
|
@@ -280,10 +280,10 @@ export declare function and<A, B extends A, C extends B>(precondition: Refinemen
|
|
|
280
280
|
* const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
|
|
281
281
|
* @see and
|
|
282
282
|
*/
|
|
283
|
-
export declare function andAll<A>(precondition: Guard<A>): Guard<A>;
|
|
284
|
-
export declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
|
|
285
|
-
export declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
|
|
286
|
-
export declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
|
|
283
|
+
export declare function andAll<A>(precondition: Guard$1<A>): Guard$1<A>;
|
|
284
|
+
export declare function andAll<A, B extends A>(precondition: Guard$1<A>, step1: Refine<A, B>): Guard$1<B>;
|
|
285
|
+
export declare function andAll<A, B extends A, C extends B>(precondition: Guard$1<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard$1<C>;
|
|
286
|
+
export declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard$1<A>, ...steps: Chain & RefineChain<A, Chain>): Guard$1<ChainResult<A, Chain>>;
|
|
287
287
|
export declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
|
|
288
288
|
export declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
|
|
289
289
|
export declare function andAll<A, B extends A, C extends B, D extends C>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>, step2: Refine<NoInfer<C>, D>): Refinement<A, D>;
|
|
@@ -302,7 +302,7 @@ export declare function andAll<A, B extends A>(precondition: Refinement<A, B>, .
|
|
|
302
302
|
* const isId = or(isString, isNumber);
|
|
303
303
|
* @see oneOf
|
|
304
304
|
*/
|
|
305
|
-
export declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
|
|
305
|
+
export declare function or<P extends readonly Guard$1<unknown>[]>(...guards: P): Guard$1<OutOfGuards<P>>;
|
|
306
306
|
export declare function or<A, B extends A, Rest extends readonly Refinement<A, A>[]>(first: Refinement<A, B>, ...rest: Rest): Refinement<A, B | GuardedOf<Rest[number]>>;
|
|
307
307
|
/**
|
|
308
308
|
* Adapts a guard so it can be used as a refinement within a known supertype.
|
|
@@ -310,7 +310,7 @@ export declare function or<A, B extends A, Rest extends readonly Refinement<A, A
|
|
|
310
310
|
* @returns Function that converts a `Guard<T>` into a `Refine<A, T>` when `T extends A`.
|
|
311
311
|
* @see and
|
|
312
312
|
*/
|
|
313
|
-
export declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
|
|
313
|
+
export declare function guardIn<A>(): <T extends A>(guard: Guard$1<T>) => Refine<A, T>;
|
|
314
314
|
/**
|
|
315
315
|
* Logical negation of a guard/refinement.
|
|
316
316
|
* Use this when a negated predicate should be named and reused.
|
|
@@ -320,7 +320,7 @@ export declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A
|
|
|
320
320
|
* @example
|
|
321
321
|
* const isPresent = not(isNil);
|
|
322
322
|
*/
|
|
323
|
-
export declare function not<A, T>(guard: Guard<T>): Refine<A, Exclude<A, Extract<A, T>>>;
|
|
323
|
+
export declare function not<A, T>(guard: Guard$1<T>): Refine<A, Exclude<A, Extract<A, T>>>;
|
|
324
324
|
export declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A, B>>;
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region src/core/nullish.d.ts
|
|
@@ -335,7 +335,7 @@ export declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exc
|
|
|
335
335
|
* const isNullableString = nullable(isString);
|
|
336
336
|
* @see nullish
|
|
337
337
|
*/
|
|
338
|
-
export declare function nullable<T>(guard: Guard<T>): Guard<T | null>;
|
|
338
|
+
export declare function nullable<T>(guard: Guard$1<T>): Guard$1<T | null>;
|
|
339
339
|
export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
|
|
340
340
|
/**
|
|
341
341
|
* Excludes `null` from the accepted values.
|
|
@@ -345,7 +345,7 @@ export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
345
345
|
* @example
|
|
346
346
|
* const isNonNullString = nonNull(nullable(isString));
|
|
347
347
|
*/
|
|
348
|
-
export declare function nonNull<T>(guard: Guard<T>): Guard<Exclude<T, null>>;
|
|
348
|
+
export declare function nonNull<T>(guard: Guard$1<T>): Guard$1<Exclude<T, null>>;
|
|
349
349
|
export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A, null>, Exclude<B, null>>;
|
|
350
350
|
/**
|
|
351
351
|
* Allows `null` or `undefined` in addition to values accepted by the guard.
|
|
@@ -358,7 +358,7 @@ export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Ex
|
|
|
358
358
|
* const isNullishString = nullish(isString);
|
|
359
359
|
* @see isNil
|
|
360
360
|
*/
|
|
361
|
-
export declare function nullish<T>(guard: Guard<T>): Guard<T | null | undefined>;
|
|
361
|
+
export declare function nullish<T>(guard: Guard$1<T>): Guard$1<T | null | undefined>;
|
|
362
362
|
export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null | undefined, B | null | undefined>;
|
|
363
363
|
/**
|
|
364
364
|
* Allows `undefined` in addition to values accepted by the guard.
|
|
@@ -370,7 +370,7 @@ export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
370
370
|
* @example
|
|
371
371
|
* const isOptionalString = optional(isString);
|
|
372
372
|
*/
|
|
373
|
-
export declare function optional<T>(guard: Guard<T>): Guard<T | undefined>;
|
|
373
|
+
export declare function optional<T>(guard: Guard$1<T>): Guard$1<T | undefined>;
|
|
374
374
|
export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
|
|
375
375
|
/**
|
|
376
376
|
* Requires a value to be present (excludes `undefined`).
|
|
@@ -380,7 +380,7 @@ export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A
|
|
|
380
380
|
* @example
|
|
381
381
|
* const isRequiredString = required(optional(isString));
|
|
382
382
|
*/
|
|
383
|
-
export declare function required<T>(guard: Guard<T | undefined>): Guard<T>;
|
|
383
|
+
export declare function required<T>(guard: Guard$1<T | undefined>): Guard$1<T>;
|
|
384
384
|
export declare function required<A, B extends A>(refine: Refine<A | undefined, B | undefined>): Refine<A, B>;
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/core/parse.d.ts
|
|
@@ -391,7 +391,7 @@ export declare function required<A, B extends A>(refine: Refine<A | undefined, B
|
|
|
391
391
|
* @param value Value to check.
|
|
392
392
|
* @returns `{ valid: true, value }` when the guard passes; `{ valid: false }` otherwise.
|
|
393
393
|
*/
|
|
394
|
-
export declare function safeParse<T>(guard: Guard<T>, value: unknown): ParseResult<T>;
|
|
394
|
+
export declare function safeParse<T>(guard: Guard$1<T>, value: unknown): ParseResult<T>;
|
|
395
395
|
export declare function safeParse<A, B extends A>(refine: Refine<A, B>, value: A): ParseResult<B>;
|
|
396
396
|
export declare function safeParse(fn: (value: unknown) => boolean, value: unknown): ParseResult<unknown>;
|
|
397
397
|
/**
|
|
@@ -400,7 +400,7 @@ export declare function safeParse(fn: (value: unknown) => boolean, value: unknow
|
|
|
400
400
|
* @param guard Guard/refinement to evaluate.
|
|
401
401
|
* @returns Function that takes a value and returns the `ParseResult`.
|
|
402
402
|
*/
|
|
403
|
-
export declare function safeParseWith<T>(guard: Guard<T>): (value: unknown) => ParseResult<T>;
|
|
403
|
+
export declare function safeParseWith<T>(guard: Guard$1<T>): (value: unknown) => ParseResult<T>;
|
|
404
404
|
export declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
|
|
405
405
|
/**
|
|
406
406
|
* Decodes JSON text and validates the decoded value without coercion.
|
|
@@ -565,7 +565,7 @@ export declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
|
|
|
565
565
|
*
|
|
566
566
|
* @returns Predicate narrowing to `Primitive`.
|
|
567
567
|
*/
|
|
568
|
-
export declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
568
|
+
export declare const isPrimitive: Guard$1<string | number | bigint | boolean | symbol | null | undefined>;
|
|
569
569
|
//#endregion
|
|
570
570
|
//#region src/core/object.d.ts
|
|
571
571
|
type AnyFunction = (...args: never[]) => unknown;
|
|
@@ -604,31 +604,31 @@ export declare const isDate: Predicate<Date>;
|
|
|
604
604
|
*
|
|
605
605
|
* @returns Predicate narrowing to `RegExp`.
|
|
606
606
|
*/
|
|
607
|
-
export declare const isRegExp: Guard<RegExp>;
|
|
607
|
+
export declare const isRegExp: Guard$1<RegExp>;
|
|
608
608
|
/**
|
|
609
609
|
* Checks whether a value is a `Map`.
|
|
610
610
|
*
|
|
611
611
|
* @returns Predicate narrowing to `Map<unknown, unknown>`.
|
|
612
612
|
*/
|
|
613
|
-
export declare const isMap: Guard<Map<unknown, unknown>>;
|
|
613
|
+
export declare const isMap: Guard$1<Map<unknown, unknown>>;
|
|
614
614
|
/**
|
|
615
615
|
* Checks whether a value is a `Set`.
|
|
616
616
|
*
|
|
617
617
|
* @returns Predicate narrowing to `Set<unknown>`.
|
|
618
618
|
*/
|
|
619
|
-
export declare const isSet: Guard<Set<unknown>>;
|
|
619
|
+
export declare const isSet: Guard$1<Set<unknown>>;
|
|
620
620
|
/**
|
|
621
621
|
* Checks whether a value is a `WeakMap`.
|
|
622
622
|
*
|
|
623
623
|
* @returns Predicate narrowing to `WeakMap<object, unknown>`.
|
|
624
624
|
*/
|
|
625
|
-
export declare const isWeakMap: Guard<WeakMap<object, unknown>>;
|
|
625
|
+
export declare const isWeakMap: Guard$1<WeakMap<object, unknown>>;
|
|
626
626
|
/**
|
|
627
627
|
* Checks whether a value is a `WeakSet`.
|
|
628
628
|
*
|
|
629
629
|
* @returns Predicate narrowing to `WeakSet<object>`.
|
|
630
630
|
*/
|
|
631
|
-
export declare const isWeakSet: Guard<WeakSet<object>>;
|
|
631
|
+
export declare const isWeakSet: Guard$1<WeakSet<object>>;
|
|
632
632
|
/**
|
|
633
633
|
* Checks whether a value is promise-like (has a `then` function).
|
|
634
634
|
*
|
|
@@ -652,13 +652,13 @@ export declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
|
|
|
652
652
|
*
|
|
653
653
|
* @returns Predicate narrowing to `ArrayBuffer`.
|
|
654
654
|
*/
|
|
655
|
-
export declare const isArrayBuffer: Guard<ArrayBuffer>;
|
|
655
|
+
export declare const isArrayBuffer: Guard$1<ArrayBuffer>;
|
|
656
656
|
/**
|
|
657
657
|
* Checks whether a value is a `DataView`.
|
|
658
658
|
*
|
|
659
659
|
* @returns Predicate narrowing to `DataView`.
|
|
660
660
|
*/
|
|
661
|
-
export declare const isDataView: Guard<DataView<ArrayBufferLike>>;
|
|
661
|
+
export declare const isDataView: Guard$1<DataView<ArrayBufferLike>>;
|
|
662
662
|
/**
|
|
663
663
|
* Checks whether a value is a typed array view (any `ArrayBufferView` except DataView).
|
|
664
664
|
*
|
|
@@ -676,26 +676,26 @@ export declare const isError: Predicate<Error>;
|
|
|
676
676
|
*
|
|
677
677
|
* @returns Predicate narrowing to `URL` when supported; otherwise always false.
|
|
678
678
|
*/
|
|
679
|
-
export declare const isURL: Guard<URL>;
|
|
679
|
+
export declare const isURL: Guard$1<URL>;
|
|
680
680
|
/**
|
|
681
681
|
* Checks whether a value is a `Blob` (in environments with Blob available).
|
|
682
682
|
*
|
|
683
683
|
* @returns Predicate narrowing to `Blob` when supported; otherwise always false.
|
|
684
684
|
*/
|
|
685
|
-
export declare const isBlob: Guard<Blob>;
|
|
685
|
+
export declare const isBlob: Guard$1<Blob>;
|
|
686
686
|
/**
|
|
687
687
|
* Checks whether a value is a `File` (in environments with File available).
|
|
688
688
|
*
|
|
689
689
|
* @returns Predicate narrowing to `File` when supported; otherwise always false.
|
|
690
690
|
*/
|
|
691
|
-
export declare const isFile: Guard<File>;
|
|
691
|
+
export declare const isFile: Guard$1<File>;
|
|
692
692
|
/**
|
|
693
693
|
* Creates a guard that checks whether a value is an instance of `constructor`.
|
|
694
694
|
*
|
|
695
695
|
* @param constructor Constructor used as the right-hand side of `instanceof`.
|
|
696
696
|
* @returns Predicate narrowing to `InstanceType<C>`.
|
|
697
697
|
*/
|
|
698
|
-
export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard<InstanceType<C>>;
|
|
698
|
+
export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard$1<InstanceType<C>>;
|
|
699
699
|
//#endregion
|
|
700
700
|
//#region src/core/combinators/array.d.ts
|
|
701
701
|
/**
|
|
@@ -713,6 +713,37 @@ export declare function arrayOf<F extends Predicate<unknown>>(elementGuard: F):
|
|
|
713
713
|
*/
|
|
714
714
|
export declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
|
|
715
715
|
//#endregion
|
|
716
|
+
//#region src/core/combinators/discriminated-union.d.ts
|
|
717
|
+
type DiscriminantValue = PropertyKey | boolean;
|
|
718
|
+
type IsFixedDiscriminantValue<Value extends DiscriminantValue> = Value extends unknown ? Value extends boolean ? true : Value extends PropertyKey ? {} extends Record<Value, unknown> ? false : true : false : never;
|
|
719
|
+
type IsFiniteDiscriminantValue<Values extends DiscriminantValue> = false extends IsFixedDiscriminantValue<Values> ? false : true;
|
|
720
|
+
type DiscriminantKey<T extends object> = { [K in keyof T]-?: [T] extends [Record<K, DiscriminantValue>] ? IsFiniteDiscriminantValue<T[K] & DiscriminantValue> extends true ? K : never : never; }[keyof T];
|
|
721
|
+
type DiscriminantValues<T extends object, K extends DiscriminantKey<T>> = T extends Record<K, infer Value> ? Value & DiscriminantValue : never;
|
|
722
|
+
type DiscriminantMapKey<Value extends DiscriminantValue> = Value extends boolean ? `${Value}` : Value;
|
|
723
|
+
type DiscriminantRuntimeKey<Value extends DiscriminantValue> = Value extends symbol ? Value : Value extends string | number | boolean ? `${Value}` : never;
|
|
724
|
+
type CollidingDiscriminantValues<Values extends DiscriminantValue, AllValues extends DiscriminantValue = Values> = Values extends unknown ? DiscriminantRuntimeKey<Values> extends DiscriminantRuntimeKey<Exclude<AllValues, Values>> ? Values : never : never;
|
|
725
|
+
type NonCollidingDiscriminants<T extends object, K extends DiscriminantKey<T>> = [CollidingDiscriminantValues<DiscriminantValues<T, K>>] extends [never] ? unknown : never;
|
|
726
|
+
type IsUnion<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
|
|
727
|
+
type HasUnionElement<Values extends readonly unknown[]> = Values extends readonly [infer Head, ...infer Tail extends readonly unknown[]] ? true extends IsUnion<Head> ? true : HasUnionElement<Tail> : false;
|
|
728
|
+
type ExactDiscriminantValues<T extends object, K extends DiscriminantKey<T>, Values extends readonly DiscriminantValue[]> = Values extends unknown ? number extends Values['length'] ? never : HasUnionElement<Values> extends true ? never : [DiscriminantValues<T, K>] extends [Values[number]] ? [Values[number]] extends [DiscriminantValues<T, K>] ? unknown : never : never : never;
|
|
729
|
+
type MatchingDiscriminantMember<T extends object, K extends DiscriminantKey<T>, Value extends DiscriminantValue> = T extends Record<K, DiscriminantValue> ? Value extends T[K] ? T : never : never;
|
|
730
|
+
type DiscriminatedUnionGuardMap<T extends object, K extends DiscriminantKey<T>, Values extends DiscriminantValue> = { readonly [Value in Values as DiscriminantMapKey<Value>]: Predicate<MatchingDiscriminantMember<T, K, Value>>; };
|
|
731
|
+
type InvalidGuardDiscriminantValues<K extends PropertyKey, Values extends DiscriminantValue, G extends object> = { [Value in Values as DiscriminantMapKey<Value>]: G extends Record<DiscriminantMapKey<Value>, infer Guard> ? GuardedOf<Guard> extends Record<K, DiscriminantValue> ? Value extends GuardedOf<Guard>[K] ? never : Value : Value : Value; }[DiscriminantMapKey<Values>];
|
|
732
|
+
type GuardsMatchDiscriminantValues<K extends PropertyKey, Values extends DiscriminantValue, G extends object> = [InvalidGuardDiscriminantValues<K, Values, G>] extends [never] ? unknown : never;
|
|
733
|
+
/**
|
|
734
|
+
* Creates an exhaustive guard for a union whose members share a literal discriminant.
|
|
735
|
+
* A tuple of every discriminant value keeps finite coverage explicit at runtime
|
|
736
|
+
* and compile time. Values that coerce to the same object key, such as `1` and
|
|
737
|
+
* `'1'`, are rejected.
|
|
738
|
+
* Use `['__proto__']` for that literal discriminant so it becomes an own map key.
|
|
739
|
+
*
|
|
740
|
+
* @param discriminant Required property that identifies each union member.
|
|
741
|
+
* @param values Finite tuple containing every discriminant value.
|
|
742
|
+
* @param guards Branch guards keyed by the discriminant values.
|
|
743
|
+
* @returns Predicate narrowing to the union accepted by the branch guards.
|
|
744
|
+
*/
|
|
745
|
+
export declare function discriminatedUnion<T extends object>(): <const K extends DiscriminantKey<T>, const Values extends readonly DiscriminantValue[], const G extends DiscriminatedUnionGuardMap<T, K, Values[number]>>(discriminant: K, values: Values & ExactDiscriminantValues<T, K, Values>, guards: NoExtraKeys<G, DiscriminatedUnionGuardMap<T, K, Values[number]>> & NonCollidingDiscriminants<T, K> & GuardsMatchDiscriminantValues<K, Values[number], G>) => Predicate<GuardedOf<G[keyof G]>>;
|
|
746
|
+
//#endregion
|
|
716
747
|
//#region src/core/combinators/map.d.ts
|
|
717
748
|
/**
|
|
718
749
|
* Validates a map where every key and value satisfies the provided guards.
|
|
@@ -880,4 +911,4 @@ export declare const everyOwnEnumerableEntry: (values: Record<string, unknown>,
|
|
|
880
911
|
*/
|
|
881
912
|
export declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
882
913
|
//#endregion
|
|
883
|
-
export type { ChainResult, Guard, GuardedOf, GuardedWithin, InferSchema, NoExtraKeys, OptionalObjectKeys, OptionalSchemaField, OutOfGuards, ParseResult, Predicate, Primitive, Refine, RefineChain, Refinement, RequiredObjectKeys, Schema, SchemaField, StructOptions, TypedStructFields, TypedStructShape };
|
|
914
|
+
export type { ChainResult, Guard$1 as Guard, GuardedOf, GuardedWithin, InferSchema, NoExtraKeys, OptionalObjectKeys, OptionalSchemaField, OutOfGuards, ParseResult, Predicate, Primitive, Refine, RefineChain, Refinement, RequiredObjectKeys, Schema, SchemaField, StructOptions, TypedStructFields, TypedStructShape };
|
package/dist/index.js
CHANGED
|
@@ -630,6 +630,52 @@ function nonEmptyArrayOf(elementGuard) {
|
|
|
630
630
|
return define((input) => Array.isArray(input) && input.length > 0 && everyArrayValue(input, elementGuard));
|
|
631
631
|
}
|
|
632
632
|
//#endregion
|
|
633
|
+
//#region src/core/combinators/discriminated-union.ts
|
|
634
|
+
const isDiscriminantValue = (value) => isString(value) || isNumberPrimitive(value) || isSymbol(value) || isBoolean(value);
|
|
635
|
+
const toRuntimeKey = (value) => isSymbol(value) ? value : String(value);
|
|
636
|
+
const assertSafeProtoBranch = (values, guards) => {
|
|
637
|
+
if (!values.includes("__proto__")) return;
|
|
638
|
+
if (hasOwnPropertyKey(guards, "__proto__")) return;
|
|
639
|
+
if (isFunction(Object.getPrototypeOf(guards))) throw new TypeError("Use ['__proto__'] for a discriminatedUnion branch key so it is an own property.");
|
|
640
|
+
};
|
|
641
|
+
const assertBranchKeys = (values, guards) => {
|
|
642
|
+
const keys = /* @__PURE__ */ new Set();
|
|
643
|
+
for (const value of values) {
|
|
644
|
+
const key = toRuntimeKey(value);
|
|
645
|
+
if (keys.has(key)) throw new TypeError(`Duplicate discriminatedUnion discriminant value for ${String(value)}.`);
|
|
646
|
+
keys.add(key);
|
|
647
|
+
if (!hasOwnPropertyKey(guards, key)) throw new TypeError(`Missing discriminatedUnion branch guard for ${String(value)}.`);
|
|
648
|
+
}
|
|
649
|
+
return keys;
|
|
650
|
+
};
|
|
651
|
+
/**
|
|
652
|
+
* Creates an exhaustive guard for a union whose members share a literal discriminant.
|
|
653
|
+
* A tuple of every discriminant value keeps finite coverage explicit at runtime
|
|
654
|
+
* and compile time. Values that coerce to the same object key, such as `1` and
|
|
655
|
+
* `'1'`, are rejected.
|
|
656
|
+
* Use `['__proto__']` for that literal discriminant so it becomes an own map key.
|
|
657
|
+
*
|
|
658
|
+
* @param discriminant Required property that identifies each union member.
|
|
659
|
+
* @param values Finite tuple containing every discriminant value.
|
|
660
|
+
* @param guards Branch guards keyed by the discriminant values.
|
|
661
|
+
* @returns Predicate narrowing to the union accepted by the branch guards.
|
|
662
|
+
*/
|
|
663
|
+
function discriminatedUnion() {
|
|
664
|
+
return (discriminant, values, guards) => {
|
|
665
|
+
assertSafeProtoBranch(values, guards);
|
|
666
|
+
const declaredKeys = assertBranchKeys(values, guards);
|
|
667
|
+
return define((input) => {
|
|
668
|
+
if (!isObject(input) && !isFunction(input) || !hasOwnPropertyKey(input, discriminant)) return false;
|
|
669
|
+
const value = Reflect.get(input, discriminant);
|
|
670
|
+
if (!isDiscriminantValue(value)) return false;
|
|
671
|
+
const key = toRuntimeKey(value);
|
|
672
|
+
if (!declaredKeys.has(key) || !hasOwnPropertyKey(guards, key)) return false;
|
|
673
|
+
const guard = guards[key];
|
|
674
|
+
return guard(input);
|
|
675
|
+
});
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
633
679
|
//#region src/core/combinators/map.ts
|
|
634
680
|
/**
|
|
635
681
|
* Validates a map where every key and value satisfies the provided guards.
|
|
@@ -796,6 +842,7 @@ exports.andAll = andAll;
|
|
|
796
842
|
exports.arrayOf = arrayOf;
|
|
797
843
|
exports.assert = assert;
|
|
798
844
|
exports.define = define;
|
|
845
|
+
exports.discriminatedUnion = discriminatedUnion;
|
|
799
846
|
exports.equals = equals;
|
|
800
847
|
exports.equalsBy = equalsBy;
|
|
801
848
|
exports.equalsKey = equalsKey;
|
package/dist/index.mjs
CHANGED
|
@@ -629,6 +629,52 @@ function nonEmptyArrayOf(elementGuard) {
|
|
|
629
629
|
return define((input) => Array.isArray(input) && input.length > 0 && everyArrayValue(input, elementGuard));
|
|
630
630
|
}
|
|
631
631
|
//#endregion
|
|
632
|
+
//#region src/core/combinators/discriminated-union.ts
|
|
633
|
+
const isDiscriminantValue = (value) => isString(value) || isNumberPrimitive(value) || isSymbol(value) || isBoolean(value);
|
|
634
|
+
const toRuntimeKey = (value) => isSymbol(value) ? value : String(value);
|
|
635
|
+
const assertSafeProtoBranch = (values, guards) => {
|
|
636
|
+
if (!values.includes("__proto__")) return;
|
|
637
|
+
if (hasOwnPropertyKey(guards, "__proto__")) return;
|
|
638
|
+
if (isFunction(Object.getPrototypeOf(guards))) throw new TypeError("Use ['__proto__'] for a discriminatedUnion branch key so it is an own property.");
|
|
639
|
+
};
|
|
640
|
+
const assertBranchKeys = (values, guards) => {
|
|
641
|
+
const keys = /* @__PURE__ */ new Set();
|
|
642
|
+
for (const value of values) {
|
|
643
|
+
const key = toRuntimeKey(value);
|
|
644
|
+
if (keys.has(key)) throw new TypeError(`Duplicate discriminatedUnion discriminant value for ${String(value)}.`);
|
|
645
|
+
keys.add(key);
|
|
646
|
+
if (!hasOwnPropertyKey(guards, key)) throw new TypeError(`Missing discriminatedUnion branch guard for ${String(value)}.`);
|
|
647
|
+
}
|
|
648
|
+
return keys;
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* Creates an exhaustive guard for a union whose members share a literal discriminant.
|
|
652
|
+
* A tuple of every discriminant value keeps finite coverage explicit at runtime
|
|
653
|
+
* and compile time. Values that coerce to the same object key, such as `1` and
|
|
654
|
+
* `'1'`, are rejected.
|
|
655
|
+
* Use `['__proto__']` for that literal discriminant so it becomes an own map key.
|
|
656
|
+
*
|
|
657
|
+
* @param discriminant Required property that identifies each union member.
|
|
658
|
+
* @param values Finite tuple containing every discriminant value.
|
|
659
|
+
* @param guards Branch guards keyed by the discriminant values.
|
|
660
|
+
* @returns Predicate narrowing to the union accepted by the branch guards.
|
|
661
|
+
*/
|
|
662
|
+
function discriminatedUnion() {
|
|
663
|
+
return (discriminant, values, guards) => {
|
|
664
|
+
assertSafeProtoBranch(values, guards);
|
|
665
|
+
const declaredKeys = assertBranchKeys(values, guards);
|
|
666
|
+
return define((input) => {
|
|
667
|
+
if (!isObject(input) && !isFunction(input) || !hasOwnPropertyKey(input, discriminant)) return false;
|
|
668
|
+
const value = Reflect.get(input, discriminant);
|
|
669
|
+
if (!isDiscriminantValue(value)) return false;
|
|
670
|
+
const key = toRuntimeKey(value);
|
|
671
|
+
if (!declaredKeys.has(key) || !hasOwnPropertyKey(guards, key)) return false;
|
|
672
|
+
const guard = guards[key];
|
|
673
|
+
return guard(input);
|
|
674
|
+
});
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
//#endregion
|
|
632
678
|
//#region src/core/combinators/map.ts
|
|
633
679
|
/**
|
|
634
680
|
* Validates a map where every key and value satisfies the provided guards.
|
|
@@ -790,4 +836,4 @@ function tupleOf(...guards) {
|
|
|
790
836
|
*/
|
|
791
837
|
const toBooleanPredicates = (predicates) => predicates;
|
|
792
838
|
//#endregion
|
|
793
|
-
export { and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNotNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, refineDefinedKey, refineIndex, refineKey, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
|
839
|
+
export { and, andAll, arrayOf, assert, define, discriminatedUnion, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNotNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, refineDefinedKey, refineIndex, refineKey, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
package/package.json
CHANGED