is-kit 1.14.3 โ†’ 1.15.1

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 CHANGED
@@ -27,42 +27,66 @@
27
27
 
28
28
  `is-kit` is a lightweight, zero-dependency toolkit for building reusable TypeScript **type guards**.
29
29
 
30
- It helps you write small `isFoo` functions, compose them into **richer runtime checks**, and keep **TypeScript narrowing** natural inside regular control flow.
30
+ `is-kit` is not just a collection of `isX` helpers. Its main focus is composing
31
+ small runtime checks into reusable guards while preserving useful TypeScript
32
+ narrowing.
33
+
34
+ It helps you write small `isFoo` functions, compose them into **richer runtime
35
+ checks**, refine properties on values you already know about, and keep
36
+ **TypeScript narrowing** natural inside regular control flow. Use it at runtime
37
+ boundaries when needed, without requiring a schema-first workflow.
31
38
 
32
39
  **Runtime-safe** ๐Ÿ›ก๏ธ, **composable** ๐Ÿงฉ, and **ergonomic** โœจ without asking you to adopt a heavy schema workflow.
33
40
 
34
41
  - Build and reuse **typed guards**
35
42
  - **Compose guards** with `and`, `or`, `not`, `oneOf`
36
- - **Validate object** shapes and collections
43
+ - Use `refineKey` to narrow a **child property** while preserving its parent type
44
+ - **Validate object** shapes and collections when that is useful
37
45
  - **Parse or assert** `unknown` values without a large schema framework
38
46
 
39
- [๐Ÿ“š Documentation Site](https://is-kit.dev/) ยท
40
- [๐Ÿงญ Practical Guides](https://is-kit.dev/guides)
47
+ <a href="https://is-kit.dev/">
48
+ <img src="docs/public/document_button.png" alt="Documentation Site" width="240">
49
+ </a>
41
50
 
42
51
  > Best for **app-internal narrowing, filtering, and reusable guards**.
43
52
 
44
53
  ## ๐Ÿค” Why use `is-kit`?
45
54
 
46
- Tired of rewriting the same `isFoo` checks again and again?
55
+ Many TypeScript projects eventually grow a `utils/is.ts`, `libs/is.ts`, or
56
+ `guards.ts` file. It fills with hand-written guards that solve the same
57
+ problems across projects, are tedious to rewrite, and need manual care to keep
58
+ their TypeScript narrowing correct as they evolve.
59
+
60
+ `is-kit` exists to make those guards reusable, composable, and easier to
61
+ maintain. The goal is not to replace every validation library; it is to make
62
+ reusable TypeScript type guards easier to build, compose, and maintain.
47
63
 
48
- `is-kit` is a good fit when you want to:
64
+ It is a good fit when you want to:
49
65
 
50
66
  - **write reusable `isX`** functions instead of one-off inline checks
51
67
  - keep runtime validation **lightweight and dependency-free**
52
68
  - **narrow values directly** in `if`, `filter`, and other TypeScript control flow
53
- - **compose validation logic** from small guards instead of large schema objects
69
+ - **compose validation logic** from small guards, including property refinements
70
+
71
+ If you only need a few standalone `isX` checks, a smaller type-check utility
72
+ may be simpler. `is-kit` becomes useful when those checks need to be composed,
73
+ refined, and reused across your application while preserving TypeScript
74
+ narrowing.
54
75
 
55
- `is-kit` is probably not the best first choice if you mainly want:
76
+ Schema validators such as Zod, Valibot, and ArkType often optimize for a
77
+ different workflow. They may be a better fit when you mainly want:
56
78
 
57
79
  - rich, structured validation errors
58
80
  - schema-first workflows
59
81
  - data transformation pipelines
60
82
 
61
- In those cases, a schema validator such as `Zod` may be a better fit. (Of course, you can combine them ๐Ÿฒ)
83
+ `is-kit` is aimed at reusable runtime predicates that behave naturally as
84
+ TypeScript type guards. The approaches can also be used together: use a schema
85
+ validator where its parsing model helps, and compose `is-kit` guards wherever
86
+ ordinary narrowing and reusable predicates are the better fit.
62
87
 
63
- `is-kit` is meant to take the boring part out of writing guards, while still feeling like normal TypeScript.
64
-
65
- > Grab a coffee โ˜• and let `is-kit` handle the repetitive part.
88
+ `is-kit` is meant to take the repetitive part out of writing guards while still
89
+ feeling like normal TypeScript.
66
90
 
67
91
  ## ๐Ÿ“ฅ Install
68
92
 
@@ -107,7 +131,43 @@ import { and, define, or } from 'jsr:@nyaomaru/is-kit';
107
131
 
108
132
  ## โœจ Quick Start
109
133
 
110
- Start with a plain object guard and parse an `unknown` value.
134
+ Start by composing small guards.
135
+
136
+ ```ts
137
+ import { and, isNumber, isString, or, predicateToRefine } from 'is-kit';
138
+
139
+ const isId = or(isString, isNumber);
140
+
141
+ const isPositiveNumber = and(
142
+ isNumber,
143
+ predicateToRefine<number>((value) => value > 0)
144
+ );
145
+ ```
146
+
147
+ You can also refine one property of an already-typed parent value.
148
+
149
+ ```ts
150
+ import { isString, refineKey } from 'is-kit';
151
+
152
+ type Item = {
153
+ value: string | number;
154
+ id: number;
155
+ };
156
+
157
+ const hasStringValue = refineKey('value', isString);
158
+
159
+ declare const items: Item[];
160
+
161
+ const textItems = items.filter(hasStringValue);
162
+ // Array<Item & { value: string }>
163
+ ```
164
+
165
+ The original `Item` type is preserved while its checked `value` property is
166
+ narrowed. This lets a reusable guard carry child narrowing back to the parent
167
+ through `filter`, `find`, and control flow.
168
+
169
+ For an `unknown` value at a runtime boundary, build an object guard and parse
170
+ it.
111
171
 
112
172
  ```ts
113
173
  import { isNumber, isString, optionalKey, safeParse, struct } from 'is-kit';
@@ -513,7 +573,45 @@ if (result.valid) {
513
573
  coercion and does not depend on a transport or schema format such as HTTP or
514
574
  OpenAPI.
515
575
 
516
- ### 11. Narrow object keys
576
+ ### 11. Validate an exhaustive discriminated union
577
+
578
+ Use `discriminatedUnion<T>()` with `typedStruct` to keep both the branch
579
+ fields and the union coverage aligned with an existing TypeScript type.
580
+
581
+ ```ts
582
+ import { discriminatedUnion, isNumber, oneOfValues, typedStruct } from 'is-kit';
583
+
584
+ type Event =
585
+ { kind: 'click'; x: number; y: number } | { kind: 'scroll'; delta: number };
586
+
587
+ const eventUnion = discriminatedUnion<Event>();
588
+
589
+ export const isEvent = eventUnion('kind', ['click', 'scroll'], {
590
+ click: typedStruct<Extract<Event, { kind: 'click' }>>()({
591
+ kind: oneOfValues('click'),
592
+ x: isNumber,
593
+ y: isNumber
594
+ }),
595
+ scroll: typedStruct<Extract<Event, { kind: 'scroll' }>>()({
596
+ kind: oneOfValues('scroll'),
597
+ delta: isNumber
598
+ })
599
+ });
600
+ ```
601
+
602
+ The value tuple and object keys must each exactly match the union's
603
+ discriminant values, so adding or removing an `Event` member produces a type
604
+ error until both are updated. The tuple makes finite coverage explicit, so
605
+ broad `string`, `number`, and `symbol` discriminants and infinite
606
+ template-literal types are rejected. Boolean branches use the `true` and
607
+ `false` object keys, which is useful for `Result` types with an `ok` field.
608
+ Discriminants that would coerce to the same object key, such as `1` and `'1'`,
609
+ are rejected because they cannot be represented as separate branches.
610
+ For a `__proto__` discriminant, write the branch as `['__proto__']: guard` (or
611
+ use a null-prototype map); the uncomputed object-literal form changes the
612
+ object's prototype instead of creating a branch entry.
613
+
614
+ ### 12. Narrow object keys
517
615
 
518
616
  Use key helpers when the important part of a value is one property.
519
617
 
@@ -630,7 +728,7 @@ The library is organized around a few small building blocks:
630
728
 
631
729
  - **Primitives**: `isString`, `isNumber`, `isBoolean`, `isInteger`, ...
632
730
  - **Composition**: `define`, `and`, `andAll`, `or`, `not`, `oneOf`
633
- - **Object shapes**: `struct`, `optionalKey`, `hasKey`, `hasKeys`, `narrowKeyTo`, `refineKey`, `refineDefinedKey`, `refineIndex`
731
+ - **Object shapes**: `struct`, `typedStruct`, `discriminatedUnion`, `optionalKey`, `hasKey`, `hasKeys`, `narrowKeyTo`, `refineKey`, `refineDefinedKey`, `refineIndex`
634
732
  - **Collections**: `arrayOf`, `nonEmptyArrayOf`, `tupleOf`, `setOf`, `mapOf`, `recordOf`
635
733
  - **Literals**: `oneOfValues`, `equals`, `equalsBy`, `equalsKey`
636
734
  - **Nullish handling**: `isNil`, `isNotNil`, `nullable`, `nonNull`, `nullish`, `optional`, `required`
@@ -700,3 +798,13 @@ Requires Node 22.22.0 and pnpm 11.2.2.
700
798
  See `DEVELOPER.md` for setup details and `CONTRIBUTE.md` for contribution workflow.
701
799
 
702
800
  Pick a guard, compose it, and ship with confidence ๐Ÿš€
801
+
802
+ ## Star History
803
+
804
+ <a href="https://www.star-history.com/?repos=nyaomaru%2Fis-kit&type=date&legend=top-left">
805
+ <picture>
806
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&theme=dark&legend=top-left" />
807
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&legend=top-left" />
808
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=nyaomaru/is-kit&type=date&legend=top-left" />
809
+ </picture>
810
+ </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
@@ -529,6 +529,7 @@ const isNotNil = (value) => value !== null && value !== void 0;
529
529
  const isPrimitive = or(isString, isNumberPrimitive, isBoolean, isBigInt, isSymbol, isUndefined, isNull);
530
530
  //#endregion
531
531
  //#region src/utils/guard-collections.ts
532
+ const arrayValues = Array.prototype.values;
532
533
  const mapEntries = Map.prototype.entries;
533
534
  const setValues = Set.prototype.values;
534
535
  const everyIterableValue = (values, predicate) => {
@@ -550,6 +551,11 @@ const everyKeyValueEntry = (entries, predicate) => {
550
551
  */
551
552
  const everyArrayValue = (values, predicate) => everyIterableValue(values, predicate);
552
553
  /**
554
+ * Checks built-in Array data without invoking an instance-provided iterator.
555
+ * WHY: An Array subclass or instance may override its public iterator and throw.
556
+ */
557
+ const everyBrandedArrayValue = (values, predicate) => everyIterableValue(arrayValues.call(values), predicate);
558
+ /**
553
559
  * Checks whether a tuple matches the provided element predicates in order.
554
560
  *
555
561
  * @deprecated Use `tupleOf` for a narrowing guard or compare the tuple length
@@ -618,7 +624,7 @@ const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyI
618
624
  * @returns Predicate narrowing to a readonly array of the guarded element type.
619
625
  */
620
626
  function arrayOf(elementGuard) {
621
- return define((input) => Array.isArray(input) && everyArrayValue(input, elementGuard));
627
+ return define((input) => Array.isArray(input) && everyBrandedArrayValue(input, elementGuard));
622
628
  }
623
629
  /**
624
630
  * Validates a non-empty array where every element satisfies the provided guard.
@@ -627,7 +633,53 @@ function arrayOf(elementGuard) {
627
633
  * @returns Predicate narrowing to a readonly non-empty array of the guarded element type.
628
634
  */
629
635
  function nonEmptyArrayOf(elementGuard) {
630
- return define((input) => Array.isArray(input) && input.length > 0 && everyArrayValue(input, elementGuard));
636
+ return define((input) => Array.isArray(input) && input.length > 0 && everyBrandedArrayValue(input, elementGuard));
637
+ }
638
+ //#endregion
639
+ //#region src/core/combinators/discriminated-union.ts
640
+ const isDiscriminantValue = (value) => isString(value) || isNumberPrimitive(value) || isSymbol(value) || isBoolean(value);
641
+ const toRuntimeKey = (value) => isSymbol(value) ? value : String(value);
642
+ const assertSafeProtoBranch = (values, guards) => {
643
+ if (!values.includes("__proto__")) return;
644
+ if (hasOwnPropertyKey(guards, "__proto__")) return;
645
+ if (isFunction(Object.getPrototypeOf(guards))) throw new TypeError("Use ['__proto__'] for a discriminatedUnion branch key so it is an own property.");
646
+ };
647
+ const assertBranchKeys = (values, guards) => {
648
+ const keys = /* @__PURE__ */ new Set();
649
+ for (const value of values) {
650
+ const key = toRuntimeKey(value);
651
+ if (keys.has(key)) throw new TypeError(`Duplicate discriminatedUnion discriminant value for ${String(value)}.`);
652
+ keys.add(key);
653
+ if (!hasOwnPropertyKey(guards, key)) throw new TypeError(`Missing discriminatedUnion branch guard for ${String(value)}.`);
654
+ }
655
+ return keys;
656
+ };
657
+ /**
658
+ * Creates an exhaustive guard for a union whose members share a literal discriminant.
659
+ * A tuple of every discriminant value keeps finite coverage explicit at runtime
660
+ * and compile time. Values that coerce to the same object key, such as `1` and
661
+ * `'1'`, are rejected.
662
+ * Use `['__proto__']` for that literal discriminant so it becomes an own map key.
663
+ *
664
+ * @param discriminant Required property that identifies each union member.
665
+ * @param values Finite tuple containing every discriminant value.
666
+ * @param guards Branch guards keyed by the discriminant values.
667
+ * @returns Predicate narrowing to the union accepted by the branch guards.
668
+ */
669
+ function discriminatedUnion() {
670
+ return (discriminant, values, guards) => {
671
+ assertSafeProtoBranch(values, guards);
672
+ const declaredKeys = assertBranchKeys(values, guards);
673
+ return define((input) => {
674
+ if (!isObject(input) && !isFunction(input) || !hasOwnPropertyKey(input, discriminant)) return false;
675
+ const value = Reflect.get(input, discriminant);
676
+ if (!isDiscriminantValue(value)) return false;
677
+ const key = toRuntimeKey(value);
678
+ if (!declaredKeys.has(key) || !hasOwnPropertyKey(guards, key)) return false;
679
+ const guard = guards[key];
680
+ return guard(input);
681
+ });
682
+ };
631
683
  }
632
684
  //#endregion
633
685
  //#region src/core/combinators/map.ts
@@ -796,6 +848,7 @@ exports.andAll = andAll;
796
848
  exports.arrayOf = arrayOf;
797
849
  exports.assert = assert;
798
850
  exports.define = define;
851
+ exports.discriminatedUnion = discriminatedUnion;
799
852
  exports.equals = equals;
800
853
  exports.equalsBy = equalsBy;
801
854
  exports.equalsKey = equalsKey;
package/dist/index.mjs CHANGED
@@ -528,6 +528,7 @@ const isNotNil = (value) => value !== null && value !== void 0;
528
528
  const isPrimitive = or(isString, isNumberPrimitive, isBoolean, isBigInt, isSymbol, isUndefined, isNull);
529
529
  //#endregion
530
530
  //#region src/utils/guard-collections.ts
531
+ const arrayValues = Array.prototype.values;
531
532
  const mapEntries = Map.prototype.entries;
532
533
  const setValues = Set.prototype.values;
533
534
  const everyIterableValue = (values, predicate) => {
@@ -549,6 +550,11 @@ const everyKeyValueEntry = (entries, predicate) => {
549
550
  */
550
551
  const everyArrayValue = (values, predicate) => everyIterableValue(values, predicate);
551
552
  /**
553
+ * Checks built-in Array data without invoking an instance-provided iterator.
554
+ * WHY: An Array subclass or instance may override its public iterator and throw.
555
+ */
556
+ const everyBrandedArrayValue = (values, predicate) => everyIterableValue(arrayValues.call(values), predicate);
557
+ /**
552
558
  * Checks whether a tuple matches the provided element predicates in order.
553
559
  *
554
560
  * @deprecated Use `tupleOf` for a narrowing guard or compare the tuple length
@@ -617,7 +623,7 @@ const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyI
617
623
  * @returns Predicate narrowing to a readonly array of the guarded element type.
618
624
  */
619
625
  function arrayOf(elementGuard) {
620
- return define((input) => Array.isArray(input) && everyArrayValue(input, elementGuard));
626
+ return define((input) => Array.isArray(input) && everyBrandedArrayValue(input, elementGuard));
621
627
  }
622
628
  /**
623
629
  * Validates a non-empty array where every element satisfies the provided guard.
@@ -626,7 +632,53 @@ function arrayOf(elementGuard) {
626
632
  * @returns Predicate narrowing to a readonly non-empty array of the guarded element type.
627
633
  */
628
634
  function nonEmptyArrayOf(elementGuard) {
629
- return define((input) => Array.isArray(input) && input.length > 0 && everyArrayValue(input, elementGuard));
635
+ return define((input) => Array.isArray(input) && input.length > 0 && everyBrandedArrayValue(input, elementGuard));
636
+ }
637
+ //#endregion
638
+ //#region src/core/combinators/discriminated-union.ts
639
+ const isDiscriminantValue = (value) => isString(value) || isNumberPrimitive(value) || isSymbol(value) || isBoolean(value);
640
+ const toRuntimeKey = (value) => isSymbol(value) ? value : String(value);
641
+ const assertSafeProtoBranch = (values, guards) => {
642
+ if (!values.includes("__proto__")) return;
643
+ if (hasOwnPropertyKey(guards, "__proto__")) return;
644
+ if (isFunction(Object.getPrototypeOf(guards))) throw new TypeError("Use ['__proto__'] for a discriminatedUnion branch key so it is an own property.");
645
+ };
646
+ const assertBranchKeys = (values, guards) => {
647
+ const keys = /* @__PURE__ */ new Set();
648
+ for (const value of values) {
649
+ const key = toRuntimeKey(value);
650
+ if (keys.has(key)) throw new TypeError(`Duplicate discriminatedUnion discriminant value for ${String(value)}.`);
651
+ keys.add(key);
652
+ if (!hasOwnPropertyKey(guards, key)) throw new TypeError(`Missing discriminatedUnion branch guard for ${String(value)}.`);
653
+ }
654
+ return keys;
655
+ };
656
+ /**
657
+ * Creates an exhaustive guard for a union whose members share a literal discriminant.
658
+ * A tuple of every discriminant value keeps finite coverage explicit at runtime
659
+ * and compile time. Values that coerce to the same object key, such as `1` and
660
+ * `'1'`, are rejected.
661
+ * Use `['__proto__']` for that literal discriminant so it becomes an own map key.
662
+ *
663
+ * @param discriminant Required property that identifies each union member.
664
+ * @param values Finite tuple containing every discriminant value.
665
+ * @param guards Branch guards keyed by the discriminant values.
666
+ * @returns Predicate narrowing to the union accepted by the branch guards.
667
+ */
668
+ function discriminatedUnion() {
669
+ return (discriminant, values, guards) => {
670
+ assertSafeProtoBranch(values, guards);
671
+ const declaredKeys = assertBranchKeys(values, guards);
672
+ return define((input) => {
673
+ if (!isObject(input) && !isFunction(input) || !hasOwnPropertyKey(input, discriminant)) return false;
674
+ const value = Reflect.get(input, discriminant);
675
+ if (!isDiscriminantValue(value)) return false;
676
+ const key = toRuntimeKey(value);
677
+ if (!declaredKeys.has(key) || !hasOwnPropertyKey(guards, key)) return false;
678
+ const guard = guards[key];
679
+ return guard(input);
680
+ });
681
+ };
630
682
  }
631
683
  //#endregion
632
684
  //#region src/core/combinators/map.ts
@@ -790,4 +842,4 @@ function tupleOf(...guards) {
790
842
  */
791
843
  const toBooleanPredicates = (predicates) => predicates;
792
844
  //#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 };
845
+ 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-kit",
3
- "version": "1.14.3",
3
+ "version": "1.15.1",
4
4
  "description": "Zero-dependency TypeScript runtime validation toolkit for composable type guards and natural type narrowing.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -62,14 +62,14 @@
62
62
  "packageManager": "pnpm@11.2.2",
63
63
  "devDependencies": {
64
64
  "@types/jest": "^30.0.0",
65
- "jest": "^30.4.2",
66
- "lefthook": "^2.1.9",
67
- "oxfmt": "^0.55.0",
68
- "oxlint": "^1.70.0",
69
- "ts-jest": "^29.4.11",
65
+ "jest": "^30.5.2",
66
+ "lefthook": "^2.1.14",
67
+ "oxfmt": "^0.71.0",
68
+ "oxlint": "^1.86.0",
69
+ "ts-jest": "^29.4.14",
70
70
  "tsd": "^0.33.0",
71
71
  "tsdown": "^0.23.0",
72
- "typedoc": "^0.28.19",
72
+ "typedoc": "^0.28.20",
73
73
  "typescript": "^6.0.3"
74
74
  },
75
75
  "tsd": {