is-kit 1.14.2 → 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/dist/index.d.mts CHANGED
@@ -6,12 +6,13 @@
6
6
  * - Use nullable, optional, or nullish to widen guards for nullish values.
7
7
  * - Use struct or typedStruct for object-shape guards.
8
8
  */
9
+ //#region src/types/core.d.ts
9
10
  /** Refinement that narrows a known input type `A` to its subtype `B`. */
10
11
  type Refinement<A, B extends A> = (value: A) => value is B;
11
12
  /** Predicate that accepts an unknown value and narrows it to `T`. */
12
13
  type Predicate<T> = Refinement<unknown, T>;
13
14
  /** Readability alias for {@link Predicate}. */
14
- type Guard<T> = Predicate<T>;
15
+ type Guard$1<T> = Predicate<T>;
15
16
  /** Readability alias for {@link Refinement}. */
16
17
  type Refine<A, B extends A> = Refinement<A, B>;
17
18
  /** Validates the ordered refinement types accepted by `andAll`. */
@@ -19,28 +20,30 @@ type RefineChain<In, T extends readonly unknown[]> = T extends [] ? [] : T exten
19
20
  /** Resolves the final narrowed type produced by an ordered refinement chain. */
20
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;
21
22
  /** Extracts the union of output types from a readonly guard collection. */
22
- 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;
23
24
  /** Tagged success/failure result containing the value when valid. */
24
25
  type ParseResult<T> = {
25
- valid: true;
26
- value: T;
26
+ valid: true;
27
+ value: T;
27
28
  } | {
28
- valid: false;
29
+ valid: false;
29
30
  };
30
31
  /** Extracts the narrowed output type from a predicate or refinement. */
31
32
  type GuardedOf<F> = F extends Refinement<infer A, infer B> ? B : never;
32
33
  /** Extracts guard outputs that remain assignable to a known input type. */
33
34
  type GuardedWithin<Fs, A> = Extract<Fs extends readonly unknown[] ? GuardedOf<Fs[number]> : never, A>;
34
-
35
+ //#endregion
36
+ //#region src/types/primitive.d.ts
35
37
  /** Union of JavaScript primitive value types. */
36
38
  type Primitive = string | number | boolean | bigint | symbol | null | undefined;
37
-
39
+ //#endregion
40
+ //#region src/types/schema.d.ts
38
41
  /**
39
42
  * Marks a `struct` schema field as optional at the key level.
40
43
  */
41
44
  type OptionalSchemaField<G extends Predicate<unknown>> = Readonly<{
42
- optional: true;
43
- guard: G;
45
+ optional: true;
46
+ guard: G;
44
47
  }>;
45
48
  /**
46
49
  * Field accepted by `struct` schemas.
@@ -54,39 +57,25 @@ type Schema = Readonly<Record<string, SchemaField>>;
54
57
  * Configures object-key validation for `struct` and `typedStruct`.
55
58
  */
56
59
  type StructOptions = Readonly<{
57
- /** Rejects extra own enumerable string-key properties when enabled. */
58
- exact?: boolean;
60
+ /** Rejects extra own enumerable string-key properties when enabled. */
61
+ exact?: boolean;
59
62
  }>;
60
63
  /**
61
64
  * Object schema shape preserving concrete keys.
62
65
  */
63
- type SchemaShape<S extends object> = Readonly<{
64
- [K in keyof S]: SchemaField;
65
- }>;
66
- type Simplify<T> = {
67
- [K in keyof T]: T[K];
68
- };
66
+ type SchemaShape<S extends object> = Readonly<{ [K in keyof S]: SchemaField; }>;
67
+ type Simplify<T> = { [K in keyof T]: T[K]; };
69
68
  type InferSchemaField<F> = F extends Predicate<unknown> ? GuardedOf<F> : F extends OptionalSchemaField<infer G> ? GuardedOf<G> : never;
70
- type RequiredSchemaKeys<S extends SchemaShape<S>> = {
71
- [K in keyof S]-?: S[K] extends OptionalSchemaField<Predicate<unknown>> ? never : K;
72
- }[keyof S];
73
- type OptionalSchemaKeys<S extends SchemaShape<S>> = {
74
- [K in keyof S]-?: S[K] extends OptionalSchemaField<Predicate<unknown>> ? K : never;
75
- }[keyof S];
69
+ type RequiredSchemaKeys<S extends SchemaShape<S>> = { [K in keyof S]-?: S[K] extends OptionalSchemaField<Predicate<unknown>> ? never : K; }[keyof S];
70
+ type OptionalSchemaKeys<S extends SchemaShape<S>> = { [K in keyof S]-?: S[K] extends OptionalSchemaField<Predicate<unknown>> ? K : never; }[keyof S];
76
71
  /**
77
72
  * Infers the readonly object type produced by a `struct` schema.
78
73
  */
79
- type InferSchema<S extends SchemaShape<S>> = Simplify<{
80
- readonly [K in RequiredSchemaKeys<S>]: InferSchemaField<S[K]>;
81
- } & {
82
- readonly [K in OptionalSchemaKeys<S>]?: InferSchemaField<S[K]>;
83
- }>;
74
+ type InferSchema<S extends SchemaShape<S>> = Simplify<{ readonly [K in RequiredSchemaKeys<S>]: InferSchemaField<S[K]>; } & { readonly [K in OptionalSchemaKeys<S>]?: InferSchemaField<S[K]>; }>;
84
75
  /**
85
76
  * Extracts optional keys from an object type.
86
77
  */
87
- type OptionalObjectKeys<T> = {
88
- [K in keyof T]-?: {} extends Pick<T, K> ? K : never;
89
- }[keyof T];
78
+ type OptionalObjectKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never; }[keyof T];
90
79
  /**
91
80
  * Extracts required keys from an object type.
92
81
  */
@@ -95,22 +84,17 @@ type RequiredObjectKeys<T> = Exclude<keyof T, OptionalObjectKeys<T>>;
95
84
  * String-keyed schema shape checked against an existing object type by
96
85
  * `typedStruct`. Numeric and symbol properties are excluded.
97
86
  */
98
- type TypedStructShape<T extends object> = {
99
- readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>;
100
- } & {
101
- readonly [K in Extract<OptionalObjectKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>;
102
- };
87
+ type TypedStructShape<T extends object> = { readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>; } & { readonly [K in Extract<OptionalObjectKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>; };
103
88
  /**
104
89
  * Keeps a schema type while rejecting keys outside the expected shape.
105
90
  */
106
- type NoExtraKeys<S, Shape> = S & {
107
- readonly [K in Exclude<keyof S, keyof Shape>]: never;
108
- };
91
+ type NoExtraKeys<S, Shape> = S & { readonly [K in Exclude<keyof S, keyof Shape>]: never; };
109
92
  /**
110
93
  * Field set accepted by `typedStruct` for a target object type.
111
94
  */
112
95
  type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtraKeys<S, TypedStructShape<T>>;
113
-
96
+ //#endregion
97
+ //#region src/core/assert.d.ts
114
98
  /**
115
99
  * Asserts that a value satisfies a guard or refinement, otherwise throws.
116
100
  *
@@ -119,9 +103,10 @@ type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtr
119
103
  * @param message Optional error message when assertion fails.
120
104
  * @returns Nothing when assertion passes; throws an `Error` on failure.
121
105
  */
122
- declare function assert<T>(guard: Guard<T>, value: unknown, message?: string): asserts value is T;
123
- declare function assert<A, B extends A>(refine: Refine<A, B>, value: A, message?: string): asserts value is B;
124
-
106
+ export declare function assert<T>(guard: Guard$1<T>, value: unknown, message?: string): asserts value is T;
107
+ export declare function assert<A, B extends A>(refine: Refine<A, B>, value: A, message?: string): asserts value is B;
108
+ //#endregion
109
+ //#region src/core/define.d.ts
125
110
  /**
126
111
  * Wraps a user function as a typed predicate.
127
112
  * Prefer `define<T>(...)` when creating a reusable custom guard from a runtime
@@ -137,36 +122,32 @@ declare function assert<A, B extends A>(refine: Refine<A, B>, value: A, message?
137
122
  * (value) => isString(value) && /^[a-z0-9-]+$/.test(value)
138
123
  * );
139
124
  */
140
- declare function define<T>(fn: (value: unknown) => value is T): Predicate<T>;
141
- declare function define<T>(fn: (value: unknown) => boolean): Predicate<T>;
142
-
125
+ export declare function define<T>(fn: (value: unknown) => value is T): Predicate<T>;
126
+ export declare function define<T>(fn: (value: unknown) => boolean): Predicate<T>;
127
+ //#endregion
128
+ //#region src/core/key-internals.d.ts
143
129
  /** Detects whether a type represents more than one possible value. */
144
- 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;
145
131
  /** Keeps only one literal property key so one lookup cannot narrow other keys. */
146
- 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;
147
133
  /** Applies the singleton-key constraint to every member of a key tuple. */
148
- type SinglePropertyKeys<Keys extends readonly PropertyKey[]> = {
149
- [Index in keyof Keys]: Keys[Index] & SinglePropertyKey<Keys[Index]>;
150
- };
134
+ type SinglePropertyKeys<Keys extends readonly PropertyKey[]> = { [Index in keyof Keys]: Keys[Index] & SinglePropertyKey<Keys[Index]>; };
151
135
  /** Narrows one concrete key, or only object-ness for a multi-value key domain. */
152
- type KeyPresence<Key extends PropertyKey> = [
153
- SinglePropertyKey<Key>
154
- ] extends [never] ? object : Record<Key, unknown>;
136
+ type KeyPresence<Key extends PropertyKey> = [SinglePropertyKey<Key>] extends [never] ? object : Record<Key, unknown>;
155
137
  /** Narrows concrete key arguments, or only object-ness when any may vary. */
156
- 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;
157
139
  /** Keeps only one non-negative integer literal that identifies an array index. */
158
140
  type ArrayIndex<Index extends number> = SinglePropertyKey<Index> extends never ? never : `${Index}` extends `-${string}` ? never : `${Index}` extends `${bigint}` ? Index : never;
159
-
160
- type EqualsKeyPredicate<K extends PropertyKey, T> = [
161
- SinglePropertyKey<K>
162
- ] extends [never] ? Predicate<object> : <A extends Record<K, unknown>>(input: unknown) => input is A & Record<K, T>;
141
+ //#endregion
142
+ //#region src/core/equals.d.ts
143
+ type EqualsKeyPredicate<K extends PropertyKey, T> = [SinglePropertyKey<K>] extends [never] ? Predicate<object> : <A extends Record<K, unknown>>(input: unknown) => input is A & Record<K, T>;
163
144
  /**
164
145
  * Creates a guard that matches values equal to the provided target using `Object.is` semantics.
165
146
  *
166
147
  * @param target Target value to compare against.
167
148
  * @returns Predicate narrowing to the exact literal type of `target`.
168
149
  */
169
- declare function equals<const T>(target: T): Predicate<T>;
150
+ export declare function equals<const T>(target: T): Predicate<T>;
170
151
  /**
171
152
  * Creates a comparator builder based on a guard and selector.
172
153
  * Useful for checking whether a selected key or projection equals a target value.
@@ -175,8 +156,8 @@ declare function equals<const T>(target: T): Predicate<T>;
175
156
  * @param selector Optional selector to project the comparable key; if omitted, returns a function to supply it later.
176
157
  * @returns Function that accepts a target and returns a predicate over the original value.
177
158
  */
178
- declare function equalsBy<F extends Predicate<unknown>>(guard: F): <K>(selector: (value: GuardedOf<F>) => K) => <const T extends K>(target: T) => Predicate<GuardedOf<F>>;
179
- declare function equalsBy<F extends Predicate<unknown>, K>(guard: F, selector: (value: GuardedOf<F>) => K): <const T extends K>(target: T) => Predicate<GuardedOf<F>>;
159
+ export declare function equalsBy<F extends Predicate<unknown>>(guard: F): <K>(selector: (value: GuardedOf<F>) => K) => <const T extends K>(target: T) => Predicate<GuardedOf<F>>;
160
+ export declare function equalsBy<F extends Predicate<unknown>, K>(guard: F, selector: (value: GuardedOf<F>) => K): <const T extends K>(target: T) => Predicate<GuardedOf<F>>;
180
161
  /**
181
162
  * Creates a guard that matches objects having a key equal to the target value.
182
163
  *
@@ -185,11 +166,10 @@ declare function equalsBy<F extends Predicate<unknown>, K>(guard: F, selector: (
185
166
  * @returns Predicate with key-specific narrowing for a singleton literal key,
186
167
  * or object-only narrowing for a multi-value key domain.
187
168
  */
188
- declare function equalsKey<const K extends PropertyKey, const T>(key: K, target: T): EqualsKeyPredicate<K, T>;
189
-
190
- type NarrowKeyPredicate<A, K extends PropertyKey, T> = [
191
- SinglePropertyKey<K>
192
- ] extends [never] ? Predicate<A> : Predicate<A & Record<K, T>>;
169
+ export declare function equalsKey<const K extends PropertyKey, const T>(key: K, target: T): EqualsKeyPredicate<K, T>;
170
+ //#endregion
171
+ //#region src/core/key-guards.d.ts
172
+ type NarrowKeyPredicate<A, K extends PropertyKey, T> = [SinglePropertyKey<K>] extends [never] ? Predicate<A> : Predicate<A & Record<K, T>>;
193
173
  /**
194
174
  * Checks whether a value has the specified own key.
195
175
  *
@@ -197,7 +177,7 @@ type NarrowKeyPredicate<A, K extends PropertyKey, T> = [
197
177
  * @returns Predicate with key-specific narrowing for a singleton literal key,
198
178
  * or object-only narrowing for a multi-value key domain.
199
179
  */
200
- declare function hasKey<const K extends PropertyKey>(key: K): Predicate<KeyPresence<K>>;
180
+ export declare function hasKey<const K extends PropertyKey>(key: K): Predicate<KeyPresence<K>>;
201
181
  /**
202
182
  * Checks whether a value has all specified own keys.
203
183
  *
@@ -205,7 +185,7 @@ declare function hasKey<const K extends PropertyKey>(key: K): Predicate<KeyPrese
205
185
  * @returns Predicate with key-specific narrowing when every argument is a
206
186
  * singleton literal key, or object-only narrowing otherwise.
207
187
  */
208
- declare function hasKeys<const KS extends readonly [PropertyKey, ...PropertyKey[]]>(...keys: KS): Predicate<KeyPresences<KS>>;
188
+ export declare function hasKeys<const KS extends readonly [PropertyKey, ...PropertyKey[]]>(...keys: KS): Predicate<KeyPresences<KS>>;
209
189
  /**
210
190
  * Builds a guard that narrows a specific key to the provided literal value.
211
191
  *
@@ -219,8 +199,9 @@ declare function hasKeys<const KS extends readonly [PropertyKey, ...PropertyKey[
219
199
  * narrows a singleton `key` to that literal. Multi-value key domains preserve
220
200
  * only the base guard's type.
221
201
  */
222
- 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>;
223
-
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
+ //#endregion
204
+ //#region src/core/property-refinement.d.ts
224
205
  /**
225
206
  * Lifts a required-property refinement to its parent object.
226
207
  * @param key Single literal key of the required property to refine.
@@ -229,7 +210,7 @@ declare function narrowKeyTo<A, const K extends keyof A & PropertyKey>(guard: Gu
229
210
  * @example
230
211
  * const hasStringValue = refineKey('value', isString);
231
212
  */
232
- declare function refineKey<const K extends PropertyKey, PropertyInput, PropertyOutput extends PropertyInput>(key: K & SinglePropertyKey<K>, refinement: Refinement<PropertyInput, PropertyOutput>): <ObjectType extends Record<K, PropertyInput>>(value: ObjectType) => value is ObjectType & Record<K, PropertyOutput>;
213
+ export declare function refineKey<const K extends PropertyKey, PropertyInput, PropertyOutput extends PropertyInput>(key: K & SinglePropertyKey<K>, refinement: Refinement<PropertyInput, PropertyOutput>): <ObjectType extends Record<K, PropertyInput>>(value: ObjectType) => value is ObjectType & Record<K, PropertyOutput>;
233
214
  /**
234
215
  * Lifts a defined optional-property refinement to its parent object.
235
216
  * @param key Single literal key of the optional property to refine when defined.
@@ -238,7 +219,7 @@ declare function refineKey<const K extends PropertyKey, PropertyInput, PropertyO
238
219
  * @example
239
220
  * const hasDefinedStringLabel = refineDefinedKey('label', isString);
240
221
  */
241
- declare function refineDefinedKey<const K extends PropertyKey, PropertyInput, PropertyOutput extends PropertyInput>(key: K & SinglePropertyKey<K>, refinement: Refinement<PropertyInput, PropertyOutput>): <ObjectType extends Partial<Record<K, PropertyInput | undefined>>>(value: ObjectType) => value is ObjectType & Record<K, Exclude<PropertyOutput, undefined>>;
222
+ export declare function refineDefinedKey<const K extends PropertyKey, PropertyInput, PropertyOutput extends PropertyInput>(key: K & SinglePropertyKey<K>, refinement: Refinement<PropertyInput, PropertyOutput>): <ObjectType extends Partial<Record<K, PropertyInput | undefined>>>(value: ObjectType) => value is ObjectType & Record<K, Exclude<PropertyOutput, undefined>>;
242
223
  /**
243
224
  * Refines one defined own element of a readonly array.
244
225
  * @param index Non-negative integer literal identifying the own element.
@@ -247,10 +228,9 @@ declare function refineDefinedKey<const K extends PropertyKey, PropertyInput, Pr
247
228
  * @example
248
229
  * const hasStringAtZero = refineIndex(0, isString);
249
230
  */
250
- declare function refineIndex<const Index extends number, ElementInput, ElementOutput extends ElementInput>(index: ArrayIndex<Index>, refinement: Refinement<ElementInput, ElementOutput>): Refinement<readonly ElementInput[], readonly ElementInput[] & {
251
- readonly [K in Index]: Exclude<ElementOutput, undefined>;
252
- }>;
253
-
231
+ export declare function refineIndex<const Index extends number, ElementInput, ElementOutput extends ElementInput>(index: ArrayIndex<Index>, refinement: Refinement<ElementInput, ElementOutput>): Refinement<readonly ElementInput[], readonly ElementInput[] & { readonly [K in Index]: Exclude<ElementOutput, undefined>; }>;
232
+ //#endregion
233
+ //#region src/core/lazy.d.ts
254
234
  /**
255
235
  * Creates a predicate whose implementation is initialized on first use.
256
236
  *
@@ -260,22 +240,16 @@ declare function refineIndex<const Index extends number, ElementInput, ElementOu
260
240
  * @param factory Function that creates the predicate when it is first evaluated.
261
241
  * @returns Predicate that delegates to the lazily initialized implementation.
262
242
  */
263
- declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
264
-
265
- type RefinementInputs<In, Outputs extends readonly unknown[]> = readonly [
266
- In,
267
- ...Outputs
268
- ];
243
+ export declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
244
+ //#endregion
245
+ //#region src/core/refinement-internals.d.ts
246
+ type RefinementInputs<In, Outputs extends readonly unknown[]> = readonly [In, ...Outputs];
269
247
  /** Builds an ordered refinement tuple from its initial input and output tuple. */
270
- type RefinementsFromOutputs<In, Outputs extends readonly unknown[]> = {
271
- [K in keyof Outputs]: Refinement<RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>], Outputs[K] & RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>]>;
272
- };
248
+ type RefinementsFromOutputs<In, Outputs extends readonly unknown[]> = { [K in keyof Outputs]: Refinement<RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>], Outputs[K] & RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>]>; };
273
249
  /** Returns the last tuple member, or a fallback for an empty tuple. */
274
- type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
275
- ...unknown[],
276
- infer Tail
277
- ] ? Tail : Default;
278
-
250
+ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [...unknown[], infer Tail] ? Tail : Default;
251
+ //#endregion
252
+ //#region src/core/logic.d.ts
279
253
  /**
280
254
  * Combines a precondition refinement with an additional refinement.
281
255
  * Prefer this over hand-written `precondition(x) && condition(x)` when the
@@ -291,8 +265,8 @@ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
291
265
  * );
292
266
  * @see andAll
293
267
  */
294
- declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
295
- declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
268
+ export declare function and<A, B extends A>(precondition: Guard$1<A>, condition: Refine<A, B>): Predicate<B>;
269
+ export declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
296
270
  /**
297
271
  * Chains refinements while preserving the precondition's input domain.
298
272
  * Use this instead of nested `&&` checks when each step should keep narrowing
@@ -306,17 +280,17 @@ declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>
306
280
  * const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
307
281
  * @see and
308
282
  */
309
- declare function andAll<A>(precondition: Guard<A>): Guard<A>;
310
- declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
311
- declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
312
- declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
313
- declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
314
- declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
315
- 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>;
316
- declare function andAll<A, B extends A, Chain extends readonly unknown[]>(precondition: Refinement<A, B>, ...steps: Chain & RefineChain<NoInfer<B>, Chain>): Refinement<A, ChainResult<B, Chain>>;
317
- declare function andAll<A, B extends A, Outputs extends readonly B[]>(precondition: Refinement<A, B>, steps: RefinementsFromOutputs<NoInfer<B>, Outputs>): Refinement<A, LastOr<B, Outputs>>;
318
- declare function andAll<A, B extends A, Outputs extends B[]>(precondition: Refinement<A, B>, ...steps: readonly unknown[] & RefinementsFromOutputs<B, Outputs>): Refinement<A, LastOr<B, Outputs>>;
319
- declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps: readonly Refine<NoInfer<B>, NoInfer<B>>[]): Refinement<A, B>;
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
+ export declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
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
+ 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>;
290
+ export declare function andAll<A, B extends A, Chain extends readonly unknown[]>(precondition: Refinement<A, B>, ...steps: Chain & RefineChain<NoInfer<B>, Chain>): Refinement<A, ChainResult<B, Chain>>;
291
+ export declare function andAll<A, B extends A, Outputs extends readonly B[]>(precondition: Refinement<A, B>, steps: RefinementsFromOutputs<NoInfer<B>, Outputs>): Refinement<A, LastOr<B, Outputs>>;
292
+ export declare function andAll<A, B extends A, Outputs extends B[]>(precondition: Refinement<A, B>, ...steps: readonly unknown[] & RefinementsFromOutputs<B, Outputs>): Refinement<A, LastOr<B, Outputs>>;
293
+ export declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps: readonly Refine<NoInfer<B>, NoInfer<B>>[]): Refinement<A, B>;
320
294
  /**
321
295
  * Logical OR over refinements sharing an input domain.
322
296
  * Prefer this over hand-written `refineA(x) || refineB(x)` when the composed
@@ -328,15 +302,15 @@ declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps
328
302
  * const isId = or(isString, isNumber);
329
303
  * @see oneOf
330
304
  */
331
- declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
332
- 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]>>;
305
+ export declare function or<P extends readonly Guard$1<unknown>[]>(...guards: P): Guard$1<OutOfGuards<P>>;
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]>>;
333
307
  /**
334
308
  * Adapts a guard so it can be used as a refinement within a known supertype.
335
309
  *
336
310
  * @returns Function that converts a `Guard<T>` into a `Refine<A, T>` when `T extends A`.
337
311
  * @see and
338
312
  */
339
- 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>;
340
314
  /**
341
315
  * Logical negation of a guard/refinement.
342
316
  * Use this when a negated predicate should be named and reused.
@@ -346,9 +320,10 @@ declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
346
320
  * @example
347
321
  * const isPresent = not(isNil);
348
322
  */
349
- declare function not<A, T>(guard: Guard<T>): Refine<A, Exclude<A, Extract<A, T>>>;
350
- declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A, B>>;
351
-
323
+ export declare function not<A, T>(guard: Guard$1<T>): Refine<A, Exclude<A, Extract<A, T>>>;
324
+ export declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A, B>>;
325
+ //#endregion
326
+ //#region src/core/nullish.d.ts
352
327
  /**
353
328
  * Allows `null` in addition to values accepted by the given guard/refinement.
354
329
  * Use this instead of hand-writing `value === null || guard(value)` when the
@@ -360,8 +335,8 @@ declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A,
360
335
  * const isNullableString = nullable(isString);
361
336
  * @see nullish
362
337
  */
363
- declare function nullable<T>(guard: Guard<T>): Guard<T | null>;
364
- declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
338
+ export declare function nullable<T>(guard: Guard$1<T>): Guard$1<T | null>;
339
+ export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
365
340
  /**
366
341
  * Excludes `null` from the accepted values.
367
342
  *
@@ -370,8 +345,8 @@ declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null
370
345
  * @example
371
346
  * const isNonNullString = nonNull(nullable(isString));
372
347
  */
373
- declare function nonNull<T>(guard: Guard<T>): Guard<Exclude<T, null>>;
374
- declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A, null>, Exclude<B, null>>;
348
+ export declare function nonNull<T>(guard: Guard$1<T>): Guard$1<Exclude<T, null>>;
349
+ export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A, null>, Exclude<B, null>>;
375
350
  /**
376
351
  * Allows `null` or `undefined` in addition to values accepted by the guard.
377
352
  * Use this instead of hand-writing `isNil(value) || guard(value)` when widening
@@ -383,8 +358,8 @@ declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A
383
358
  * const isNullishString = nullish(isString);
384
359
  * @see isNil
385
360
  */
386
- declare function nullish<T>(guard: Guard<T>): Guard<T | null | undefined>;
387
- declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null | undefined, B | null | undefined>;
361
+ export declare function nullish<T>(guard: Guard$1<T>): Guard$1<T | null | undefined>;
362
+ export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null | undefined, B | null | undefined>;
388
363
  /**
389
364
  * Allows `undefined` in addition to values accepted by the guard.
390
365
  * Use this for value-level optionality. For optional object keys in `struct`,
@@ -395,8 +370,8 @@ declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null
395
370
  * @example
396
371
  * const isOptionalString = optional(isString);
397
372
  */
398
- declare function optional<T>(guard: Guard<T>): Guard<T | undefined>;
399
- declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
373
+ export declare function optional<T>(guard: Guard$1<T>): Guard$1<T | undefined>;
374
+ export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
400
375
  /**
401
376
  * Requires a value to be present (excludes `undefined`).
402
377
  *
@@ -405,9 +380,10 @@ declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | unde
405
380
  * @example
406
381
  * const isRequiredString = required(optional(isString));
407
382
  */
408
- declare function required<T>(guard: Guard<T | undefined>): Guard<T>;
409
- declare function required<A, B extends A>(refine: Refine<A | undefined, B | undefined>): Refine<A, B>;
410
-
383
+ export declare function required<T>(guard: Guard$1<T | undefined>): Guard$1<T>;
384
+ export declare function required<A, B extends A>(refine: Refine<A | undefined, B | undefined>): Refine<A, B>;
385
+ //#endregion
386
+ //#region src/core/parse.d.ts
411
387
  /**
412
388
  * Executes a guard or refinement and returns a tagged result with the value when valid.
413
389
  *
@@ -415,17 +391,17 @@ declare function required<A, B extends A>(refine: Refine<A | undefined, B | unde
415
391
  * @param value Value to check.
416
392
  * @returns `{ valid: true, value }` when the guard passes; `{ valid: false }` otherwise.
417
393
  */
418
- declare function safeParse<T>(guard: Guard<T>, value: unknown): ParseResult<T>;
419
- declare function safeParse<A, B extends A>(refine: Refine<A, B>, value: A): ParseResult<B>;
420
- declare function safeParse(fn: (value: unknown) => boolean, value: unknown): ParseResult<unknown>;
394
+ export declare function safeParse<T>(guard: Guard$1<T>, value: unknown): ParseResult<T>;
395
+ export declare function safeParse<A, B extends A>(refine: Refine<A, B>, value: A): ParseResult<B>;
396
+ export declare function safeParse(fn: (value: unknown) => boolean, value: unknown): ParseResult<unknown>;
421
397
  /**
422
398
  * Curried variant of `safeParse` for reuse.
423
399
  *
424
400
  * @param guard Guard/refinement to evaluate.
425
401
  * @returns Function that takes a value and returns the `ParseResult`.
426
402
  */
427
- declare function safeParseWith<T>(guard: Guard<T>): (value: unknown) => ParseResult<T>;
428
- declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
403
+ export declare function safeParseWith<T>(guard: Guard$1<T>): (value: unknown) => ParseResult<T>;
404
+ export declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
429
405
  /**
430
406
  * Decodes JSON text and validates the decoded value without coercion.
431
407
  *
@@ -433,72 +409,74 @@ declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A)
433
409
  * @param guard Guard used to validate the decoded `unknown` value.
434
410
  * @returns The decoded value when valid; `{ valid: false }` for invalid JSON or a guard mismatch.
435
411
  */
436
- declare function safeJsonParse<T>(input: string, guard: Predicate<T>): ParseResult<T>;
437
-
412
+ export declare function safeJsonParse<T>(input: string, guard: Predicate<T>): ParseResult<T>;
413
+ //#endregion
414
+ //#region src/core/predicate.d.ts
438
415
  /**
439
416
  * Converts a boolean predicate into a refinement preserving the input type.
440
417
  *
441
418
  * @param fn Boolean-returning function over a value of type A.
442
419
  * @returns Refinement equivalent to the provided predicate.
443
420
  */
444
- declare const predicateToRefine: <A>(fn: (value: A) => boolean) => Refine<A, A>;
445
-
421
+ export declare const predicateToRefine: <A>(fn: (value: A) => boolean) => Refine<A, A>;
422
+ //#endregion
423
+ //#region src/core/primitive.d.ts
446
424
  /**
447
425
  * Checks whether a value is a string.
448
426
  *
449
427
  * @returns Predicate narrowing to `string`.
450
428
  */
451
- declare const isString: Predicate<string>;
429
+ export declare const isString: Predicate<string>;
452
430
  /**
453
431
  * Checks whether a value is a number primitive (may include NaN/±Infinity).
454
432
  *
455
433
  * @returns Predicate narrowing to `number` (primitive-only).
456
434
  */
457
- declare const isNumberPrimitive: Predicate<number>;
435
+ export declare const isNumberPrimitive: Predicate<number>;
458
436
  /**
459
437
  * Checks whether a value is `NaN`.
460
438
  *
461
439
  * Equivalent to `Number.isNaN(value)` without coercion.
462
440
  * @returns Predicate narrowing to `number` (`NaN` only).
463
441
  */
464
- declare const isNaN: Predicate<number>;
442
+ export declare const isNaN: Predicate<number>;
465
443
  /**
466
444
  * Checks whether a value is an infinite number (±Infinity).
467
445
  *
468
446
  * @returns Predicate narrowing to `number` (Infinity or -Infinity).
469
447
  */
470
- declare const isInfiniteNumber: Predicate<number>;
448
+ export declare const isInfiniteNumber: Predicate<number>;
471
449
  /**
472
450
  * Checks whether a number is finite.
473
451
  * @returns Refinement that accepts only finite numbers.
474
452
  */
475
- declare const isFiniteNumber: Refine<number, number>;
453
+ export declare const isFiniteNumber: Refine<number, number>;
476
454
  /**
477
455
  * Checks whether a value is a finite number.
478
456
  * @returns Predicate narrowing to finite `number`.
479
457
  */
480
- declare const isNumber: Predicate<number>;
458
+ export declare const isNumber: Predicate<number>;
481
459
  /**
482
460
  * Checks whether a value is an integer number.
483
461
  *
484
462
  * Equivalent to `Number.isInteger(value)`.
485
463
  * @returns Predicate narrowing to integer `number`.
486
464
  */
487
- declare const isInteger: Predicate<number>;
465
+ export declare const isInteger: Predicate<number>;
488
466
  /**
489
467
  * Checks whether a value is a safe integer.
490
468
  *
491
469
  * Equivalent to `Number.isSafeInteger(value)`.
492
470
  * @returns Predicate narrowing to safe-integer `number`.
493
471
  */
494
- declare const isSafeInteger: Predicate<number>;
472
+ export declare const isSafeInteger: Predicate<number>;
495
473
  /**
496
474
  * Checks whether a value is a positive finite number (> 0).
497
475
  *
498
476
  * Uses `isNumber` internally to exclude NaN and ±Infinity.
499
477
  * @returns Predicate narrowing to positive `number`.
500
478
  */
501
- declare const isPositive: Predicate<number>;
479
+ export declare const isPositive: Predicate<number>;
502
480
  /**
503
481
  * Checks whether a value is a negative finite number (< 0).
504
482
  *
@@ -506,31 +484,31 @@ declare const isPositive: Predicate<number>;
506
484
  * Note: `-0` is not considered negative (consistent with `< 0`).
507
485
  * @returns Predicate narrowing to negative `number`.
508
486
  */
509
- declare const isNegative: Predicate<number>;
487
+ export declare const isNegative: Predicate<number>;
510
488
  /**
511
489
  * Checks whether a value is a finite number that equals zero (including `-0`).
512
490
  *
513
491
  * @returns Predicate narrowing to zero `number`.
514
492
  */
515
- declare const isZero: Predicate<number>;
493
+ export declare const isZero: Predicate<number>;
516
494
  /**
517
495
  * Checks whether a value is a boolean.
518
496
  *
519
497
  * @returns Predicate narrowing to `boolean`.
520
498
  */
521
- declare const isBoolean: Predicate<boolean>;
499
+ export declare const isBoolean: Predicate<boolean>;
522
500
  /**
523
501
  * Checks whether a value is a bigint.
524
502
  *
525
503
  * @returns Predicate narrowing to `bigint`.
526
504
  */
527
- declare const isBigInt: Predicate<bigint>;
505
+ export declare const isBigInt: Predicate<bigint>;
528
506
  /**
529
507
  * Checks whether a value is a symbol.
530
508
  *
531
509
  * @returns Predicate narrowing to `symbol`.
532
510
  */
533
- declare const isSymbol: Predicate<symbol>;
511
+ export declare const isSymbol: Predicate<symbol>;
534
512
  /**
535
513
  * Checks whether a value is exactly `undefined`.
536
514
  *
@@ -540,7 +518,7 @@ declare const isSymbol: Predicate<symbol>;
540
518
  * @returns Predicate narrowing to `undefined`.
541
519
  * @see isNil
542
520
  */
543
- declare const isUndefined: Predicate<undefined>;
521
+ export declare const isUndefined: Predicate<undefined>;
544
522
  /**
545
523
  * Checks whether a value is exactly `null`.
546
524
  *
@@ -550,7 +528,7 @@ declare const isUndefined: Predicate<undefined>;
550
528
  * @returns Predicate narrowing to `null`.
551
529
  * @see isNil
552
530
  */
553
- declare const isNull: Predicate<null>;
531
+ export declare const isNull: Predicate<null>;
554
532
  /**
555
533
  * Checks whether a value is `null` or `undefined` (nullish).
556
534
  *
@@ -564,7 +542,7 @@ declare const isNull: Predicate<null>;
564
542
  * isNil(undefined); // true
565
543
  * isNil(0); // false
566
544
  */
567
- declare const isNil: (value: unknown) => value is null | undefined;
545
+ export declare const isNil: (value: unknown) => value is null | undefined;
568
546
  /**
569
547
  * Checks whether a value is neither `null` nor `undefined`.
570
548
  *
@@ -578,7 +556,7 @@ declare const isNil: (value: unknown) => value is null | undefined;
578
556
  * const presentValues = values.filter(isNotNil); // string[]
579
557
  * @see isNil
580
558
  */
581
- declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
559
+ export declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
582
560
  /**
583
561
  * Checks whether a value is a JavaScript primitive.
584
562
  *
@@ -587,152 +565,186 @@ declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
587
565
  *
588
566
  * @returns Predicate narrowing to `Primitive`.
589
567
  */
590
- declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
591
-
568
+ export declare const isPrimitive: Guard$1<string | number | bigint | boolean | symbol | null | undefined>;
569
+ //#endregion
570
+ //#region src/core/object.d.ts
592
571
  type AnyFunction = (...args: never[]) => unknown;
593
572
  /**
594
573
  * Checks whether a value is a function.
595
574
  *
596
575
  * @returns Predicate narrowing to a callable value.
597
576
  */
598
- declare const isFunction: Predicate<AnyFunction>;
577
+ export declare const isFunction: Predicate<AnyFunction>;
599
578
  /**
600
579
  * Checks for non-null objects (including arrays, dates, etc.).
601
580
  *
602
581
  * @returns Predicate narrowing to `Record<PropertyKey, unknown>`.
603
582
  */
604
- declare const isObject: Predicate<Record<PropertyKey, unknown>>;
583
+ export declare const isObject: Predicate<Record<PropertyKey, unknown>>;
605
584
  /**
606
585
  * Checks for plain objects created by object literals or `Object.create(null)`.
607
586
  *
608
587
  * @returns Predicate narrowing to `Record<string, unknown>`.
609
588
  */
610
- declare const isPlainObject: Predicate<Record<string, unknown>>;
589
+ export declare const isPlainObject: Predicate<Record<string, unknown>>;
611
590
  /**
612
591
  * Checks whether a value is an array.
613
592
  *
614
593
  * @returns Predicate narrowing to `readonly unknown[]`.
615
594
  */
616
- declare const isArray: Predicate<readonly unknown[]>;
595
+ export declare const isArray: Predicate<readonly unknown[]>;
617
596
  /**
618
597
  * Checks whether a value is a valid `Date` instance (not `Invalid Date`).
619
598
  *
620
599
  * @returns Predicate narrowing to `Date`.
621
600
  */
622
- declare const isDate: Predicate<Date>;
601
+ export declare const isDate: Predicate<Date>;
623
602
  /**
624
603
  * Checks whether a value is a `RegExp`.
625
604
  *
626
605
  * @returns Predicate narrowing to `RegExp`.
627
606
  */
628
- declare const isRegExp: Guard<RegExp>;
607
+ export declare const isRegExp: Guard$1<RegExp>;
629
608
  /**
630
609
  * Checks whether a value is a `Map`.
631
610
  *
632
611
  * @returns Predicate narrowing to `Map<unknown, unknown>`.
633
612
  */
634
- declare const isMap: Guard<Map<unknown, unknown>>;
613
+ export declare const isMap: Guard$1<Map<unknown, unknown>>;
635
614
  /**
636
615
  * Checks whether a value is a `Set`.
637
616
  *
638
617
  * @returns Predicate narrowing to `Set<unknown>`.
639
618
  */
640
- declare const isSet: Guard<Set<unknown>>;
619
+ export declare const isSet: Guard$1<Set<unknown>>;
641
620
  /**
642
621
  * Checks whether a value is a `WeakMap`.
643
622
  *
644
623
  * @returns Predicate narrowing to `WeakMap<object, unknown>`.
645
624
  */
646
- declare const isWeakMap: Guard<WeakMap<object, unknown>>;
625
+ export declare const isWeakMap: Guard$1<WeakMap<object, unknown>>;
647
626
  /**
648
627
  * Checks whether a value is a `WeakSet`.
649
628
  *
650
629
  * @returns Predicate narrowing to `WeakSet<object>`.
651
630
  */
652
- declare const isWeakSet: Guard<WeakSet<object>>;
631
+ export declare const isWeakSet: Guard$1<WeakSet<object>>;
653
632
  /**
654
633
  * Checks whether a value is promise-like (has a `then` function).
655
634
  *
656
635
  * @returns Predicate narrowing to `PromiseLike<unknown>`.
657
636
  */
658
- declare const isPromiseLike: Predicate<PromiseLike<unknown>>;
637
+ export declare const isPromiseLike: Predicate<PromiseLike<unknown>>;
659
638
  /**
660
639
  * Checks whether a value implements the `Iterable` protocol.
661
640
  *
662
641
  * @returns Predicate narrowing to `Iterable<unknown>`.
663
642
  */
664
- declare const isIterable: Predicate<Iterable<unknown>>;
643
+ export declare const isIterable: Predicate<Iterable<unknown>>;
665
644
  /**
666
645
  * Checks whether a value implements the `AsyncIterable` protocol.
667
646
  *
668
647
  * @returns Predicate narrowing to `AsyncIterable<unknown>`.
669
648
  */
670
- declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
649
+ export declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
671
650
  /**
672
651
  * Checks whether a value is an `ArrayBuffer`.
673
652
  *
674
653
  * @returns Predicate narrowing to `ArrayBuffer`.
675
654
  */
676
- declare const isArrayBuffer: Guard<ArrayBuffer>;
655
+ export declare const isArrayBuffer: Guard$1<ArrayBuffer>;
677
656
  /**
678
657
  * Checks whether a value is a `DataView`.
679
658
  *
680
659
  * @returns Predicate narrowing to `DataView`.
681
660
  */
682
- declare const isDataView: Guard<DataView<ArrayBufferLike>>;
661
+ export declare const isDataView: Guard$1<DataView<ArrayBufferLike>>;
683
662
  /**
684
663
  * Checks whether a value is a typed array view (any `ArrayBufferView` except DataView).
685
664
  *
686
665
  * @returns Predicate narrowing to `ArrayBufferView`.
687
666
  */
688
- declare const isTypedArray: Predicate<ArrayBufferView<ArrayBufferLike>>;
667
+ export declare const isTypedArray: Predicate<ArrayBufferView<ArrayBufferLike>>;
689
668
  /**
690
669
  * Checks whether a value is an `Error` (instance of Error or plain Error object tag).
691
670
  *
692
671
  * @returns Predicate narrowing to `Error`.
693
672
  */
694
- declare const isError: Predicate<Error>;
673
+ export declare const isError: Predicate<Error>;
695
674
  /**
696
675
  * Checks whether a value is a `URL` (in environments with URL available).
697
676
  *
698
677
  * @returns Predicate narrowing to `URL` when supported; otherwise always false.
699
678
  */
700
- declare const isURL: Guard<URL>;
679
+ export declare const isURL: Guard$1<URL>;
701
680
  /**
702
681
  * Checks whether a value is a `Blob` (in environments with Blob available).
703
682
  *
704
683
  * @returns Predicate narrowing to `Blob` when supported; otherwise always false.
705
684
  */
706
- declare const isBlob: Guard<Blob>;
685
+ export declare const isBlob: Guard$1<Blob>;
707
686
  /**
708
687
  * Checks whether a value is a `File` (in environments with File available).
709
688
  *
710
689
  * @returns Predicate narrowing to `File` when supported; otherwise always false.
711
690
  */
712
- declare const isFile: Guard<File>;
691
+ export declare const isFile: Guard$1<File>;
713
692
  /**
714
693
  * Creates a guard that checks whether a value is an instance of `constructor`.
715
694
  *
716
695
  * @param constructor Constructor used as the right-hand side of `instanceof`.
717
696
  * @returns Predicate narrowing to `InstanceType<C>`.
718
697
  */
719
- declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard<InstanceType<C>>;
720
-
698
+ export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard$1<InstanceType<C>>;
699
+ //#endregion
700
+ //#region src/core/combinators/array.d.ts
721
701
  /**
722
702
  * Validates an array where every element satisfies the provided guard.
723
703
  *
724
704
  * @param elementGuard Guard applied to each array element.
725
705
  * @returns Predicate narrowing to a readonly array of the guarded element type.
726
706
  */
727
- declare function arrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly GuardedOf<F>[]>;
707
+ export declare function arrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly GuardedOf<F>[]>;
728
708
  /**
729
709
  * Validates a non-empty array where every element satisfies the provided guard.
730
710
  *
731
711
  * @param elementGuard Guard applied to each array element.
732
712
  * @returns Predicate narrowing to a readonly non-empty array of the guarded element type.
733
713
  */
734
- declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
735
-
714
+ export declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
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
747
+ //#region src/core/combinators/map.d.ts
736
748
  /**
737
749
  * Validates a map where every key and value satisfies the provided guards.
738
750
  *
@@ -740,18 +752,20 @@ declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F):
740
752
  * @param valueGuard Guard applied to each map value.
741
753
  * @returns Predicate narrowing to a readonly map with guarded key/value types.
742
754
  */
743
- declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
744
-
755
+ export declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
756
+ //#endregion
757
+ //#region src/core/combinators/one-of.d.ts
745
758
  /**
746
759
  * Combines refinements sharing an input domain.
747
760
  *
748
761
  * @param refinements One or more refinements to try.
749
762
  * @returns Refinement that narrows to the union of matching types.
750
763
  */
751
- declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
752
- declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
753
- declare function oneOf<A, B extends A, Rest extends readonly Refinement<A, A>[]>(first: Refinement<A, B>, ...rest: Rest): Refinement<A, B | GuardedOf<Rest[number]>>;
754
-
764
+ export declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
765
+ export declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
766
+ export declare function oneOf<A, B extends A, Rest extends readonly Refinement<A, A>[]>(first: Refinement<A, B>, ...rest: Rest): Refinement<A, B | GuardedOf<Rest[number]>>;
767
+ //#endregion
768
+ //#region src/core/combinators/one-of-values.d.ts
755
769
  /**
756
770
  * Creates a guard that matches when the input is one of the provided literal values.
757
771
  * Uses `Object.is` for exact value semantics. For large sets, keeps O(1) lookups while
@@ -760,10 +774,11 @@ declare function oneOf<A, B extends A, Rest extends readonly Refinement<A, A>[]>
760
774
  * @param values Literal primitives to compare against (varargs or single readonly tuple array).
761
775
  * @returns Predicate narrowing to the union of the provided literal values.
762
776
  */
763
- declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values: T): Predicate<T[number]>;
764
- declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(values: T): Predicate<T[number]>;
765
- declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...valuesOrArray: T | [T]): Predicate<T[number]>;
766
-
777
+ export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values: T): Predicate<T[number]>;
778
+ export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(values: T): Predicate<T[number]>;
779
+ export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...valuesOrArray: T | [T]): Predicate<T[number]>;
780
+ //#endregion
781
+ //#region src/core/combinators/record.d.ts
767
782
  /**
768
783
  * Validates a record-like object by guarding both keys and values.
769
784
  *
@@ -771,16 +786,18 @@ declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values
771
786
  * @param valueFunction Guard applied to each value in the record.
772
787
  * @returns Predicate narrowing to a readonly record with guarded key/value types.
773
788
  */
774
- declare function recordOf<KF extends Predicate<string>, VF extends Predicate<unknown>>(keyFunction: KF, valueFunction: VF): Predicate<Readonly<Record<GuardedOf<KF>, GuardedOf<VF>>>>;
775
-
789
+ export declare function recordOf<KF extends Predicate<string>, VF extends Predicate<unknown>>(keyFunction: KF, valueFunction: VF): Predicate<Readonly<Record<GuardedOf<KF>, GuardedOf<VF>>>>;
790
+ //#endregion
791
+ //#region src/core/combinators/set.d.ts
776
792
  /**
777
793
  * Validates a set where every value satisfies the provided guard.
778
794
  *
779
795
  * @param valueGuard Guard applied to each set value.
780
796
  * @returns Predicate narrowing to a readonly set of the guarded value type.
781
797
  */
782
- declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate<ReadonlySet<GuardedOf<VF>>>;
783
-
798
+ export declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate<ReadonlySet<GuardedOf<VF>>>;
799
+ //#endregion
800
+ //#region src/core/combinators/struct.d.ts
784
801
  /**
785
802
  * Marks a struct schema field as optional at the key level.
786
803
  *
@@ -790,7 +807,7 @@ declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate
790
807
  * @param guard Guard used to validate the property value when the key exists.
791
808
  * @returns Schema field marker understood by `struct`.
792
809
  */
793
- declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSchemaField<G>;
810
+ export declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSchemaField<G>;
794
811
  /**
795
812
  * Validates an object against a field-to-guard schema.
796
813
  * Keys in the schema are required unless wrapped with `optionalKey`; optionally
@@ -801,8 +818,9 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
801
818
  * properties not in `schema`.
802
819
  * @returns Predicate that narrows to the inferred struct type.
803
820
  */
804
- declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
805
-
821
+ export declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
822
+ //#endregion
823
+ //#region src/core/combinators/typed-struct.d.ts
806
824
  /**
807
825
  * Creates a `struct` builder checked against an existing string-keyed object
808
826
  * type. Numeric and symbol properties are excluded from the checked shape and
@@ -815,18 +833,18 @@ declare function struct<const S extends SchemaShape<S>>(schema: S, options?: Str
815
833
  *
816
834
  * @returns Builder that rejects missing, extra, or incompatible struct fields.
817
835
  */
818
- declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
819
-
836
+ export declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
837
+ //#endregion
838
+ //#region src/core/combinators/tuple.d.ts
820
839
  /**
821
840
  * Validates a fixed-length tuple by applying element-wise guards.
822
841
  *
823
842
  * @param guards Guards corresponding to each tuple position.
824
843
  * @returns Predicate that narrows to a readonly tuple of guarded element types.
825
844
  */
826
- declare function tupleOf<const Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<{
827
- readonly [K in keyof Fs]: GuardedOf<Fs[K]>;
828
- }>;
829
-
845
+ export declare function tupleOf<const Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<{ readonly [K in keyof Fs]: GuardedOf<Fs[K]>; }>;
846
+ //#endregion
847
+ //#region src/utils/guard-collections.d.ts
830
848
  type BooleanPredicate<T> = (value: T) => boolean;
831
849
  /**
832
850
  * Checks whether every array element satisfies the provided predicate.
@@ -837,7 +855,7 @@ type BooleanPredicate<T> = (value: T) => boolean;
837
855
  * @param predicate Predicate applied to each element.
838
856
  * @returns Whether all elements satisfy `predicate`.
839
857
  */
840
- declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPredicate<unknown>) => boolean;
858
+ export declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPredicate<unknown>) => boolean;
841
859
  /**
842
860
  * Checks whether a tuple matches the provided element predicates in order.
843
861
  *
@@ -847,7 +865,7 @@ declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPr
847
865
  * @param predicates Predicates aligned to each tuple index.
848
866
  * @returns Whether lengths match and each index passes.
849
867
  */
850
- declare const everyTupleValue: (values: readonly unknown[], predicates: readonly BooleanPredicate<unknown>[]) => boolean;
868
+ export declare const everyTupleValue: (values: readonly unknown[], predicates: readonly BooleanPredicate<unknown>[]) => boolean;
851
869
  /**
852
870
  * Checks whether every set value satisfies the provided predicate.
853
871
  *
@@ -857,7 +875,7 @@ declare const everyTupleValue: (values: readonly unknown[], predicates: readonly
857
875
  * @param predicate Predicate applied to each value.
858
876
  * @returns Whether all set values satisfy `predicate`.
859
877
  */
860
- declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPredicate<unknown>) => boolean;
878
+ export declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPredicate<unknown>) => boolean;
861
879
  /**
862
880
  * Checks whether every map entry satisfies the provided key and value predicates.
863
881
  *
@@ -868,7 +886,7 @@ declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPr
868
886
  * @param valuePredicate Predicate applied to each value.
869
887
  * @returns Whether all keys and values satisfy their predicates.
870
888
  */
871
- declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicate: BooleanPredicate<unknown>, valuePredicate: BooleanPredicate<unknown>) => boolean;
889
+ export declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicate: BooleanPredicate<unknown>, valuePredicate: BooleanPredicate<unknown>) => boolean;
872
890
  /**
873
891
  * Checks whether every own enumerable string key/value pair satisfies the provided predicates.
874
892
  *
@@ -880,8 +898,9 @@ declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicat
880
898
  * @param valuePredicate Predicate applied to each corresponding value.
881
899
  * @returns Whether all enumerable entries satisfy their predicates.
882
900
  */
883
- declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPredicate: BooleanPredicate<string>, valuePredicate: BooleanPredicate<unknown>) => boolean;
884
-
901
+ export declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPredicate: BooleanPredicate<string>, valuePredicate: BooleanPredicate<unknown>) => boolean;
902
+ //#endregion
903
+ //#region src/utils/to-boolean-predicates.d.ts
885
904
  /**
886
905
  * Converts predicates to plain boolean predicates for iteration helpers.
887
906
  *
@@ -890,6 +909,6 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
890
909
  * @param predicates Predicates to be treated as simple boolean functions.
891
910
  * @returns Readonly array of boolean-returning functions.
892
911
  */
893
- declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
894
-
895
- export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type StructOptions, type TypedStructFields, type TypedStructShape, 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 };
912
+ export declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
913
+ //#endregion
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 };