is-kit 1.14.1 → 1.14.3
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 +38 -1
- package/dist/index.d.mts +193 -208
- package/dist/index.d.ts +193 -208
- package/dist/index.js +811 -607
- package/dist/index.mjs +729 -499
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
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`. */
|
|
@@ -22,25 +23,27 @@ type ChainResult<In, T extends readonly unknown[]> = T extends [] ? In : T exten
|
|
|
22
23
|
type OutOfGuards<T extends readonly Guard<unknown>[]> = T[number] extends Guard<infer U> ? U : never;
|
|
23
24
|
/** Tagged success/failure result containing the value when valid. */
|
|
24
25
|
type ParseResult<T> = {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
valid: true;
|
|
27
|
+
value: T;
|
|
27
28
|
} | {
|
|
28
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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<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
130
|
type IsUnion<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
132
|
type SinglePropertyKey<Key extends PropertyKey> = [Key] extends [never] ? never : true extends IsUnion<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
138
|
type KeyPresences<Keys extends readonly PropertyKey[]> = true extends IsUnion<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
|
-
|
|
161
|
-
|
|
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
|
-
|
|
191
|
-
|
|
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,41 +199,38 @@ 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<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.
|
|
227
208
|
* @param refinement Refinement applied to the property value.
|
|
228
209
|
* @returns Refinement that preserves the parent type and narrows the property.
|
|
229
210
|
* @example
|
|
230
|
-
* const
|
|
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.
|
|
236
217
|
* @param refinement Refinement applied only to a defined property value.
|
|
237
218
|
* @returns Refinement that requires and narrows the property.
|
|
238
219
|
* @example
|
|
239
|
-
* const
|
|
240
|
-
* 'initializer',
|
|
241
|
-
* ts.isCallExpression
|
|
242
|
-
* );
|
|
220
|
+
* const hasDefinedStringLabel = refineDefinedKey('label', isString);
|
|
243
221
|
*/
|
|
244
|
-
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>>;
|
|
245
223
|
/**
|
|
246
224
|
* Refines one defined own element of a readonly array.
|
|
247
225
|
* @param index Non-negative integer literal identifying the own element.
|
|
248
226
|
* @param refinement Refinement applied only to a defined element.
|
|
249
227
|
* @returns Refinement that narrows the selected index.
|
|
250
228
|
* @example
|
|
251
|
-
* const
|
|
229
|
+
* const hasStringAtZero = refineIndex(0, isString);
|
|
252
230
|
*/
|
|
253
|
-
declare function refineIndex<const Index extends number, ElementInput, ElementOutput extends ElementInput>(index: ArrayIndex<Index>, refinement: Refinement<ElementInput, ElementOutput>): Refinement<readonly ElementInput[], readonly ElementInput[] & {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
|
257
234
|
/**
|
|
258
235
|
* Creates a predicate whose implementation is initialized on first use.
|
|
259
236
|
*
|
|
@@ -263,22 +240,16 @@ declare function refineIndex<const Index extends number, ElementInput, ElementOu
|
|
|
263
240
|
* @param factory Function that creates the predicate when it is first evaluated.
|
|
264
241
|
* @returns Predicate that delegates to the lazily initialized implementation.
|
|
265
242
|
*/
|
|
266
|
-
declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
...Outputs
|
|
271
|
-
];
|
|
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];
|
|
272
247
|
/** Builds an ordered refinement tuple from its initial input and output tuple. */
|
|
273
|
-
type RefinementsFromOutputs<In, Outputs extends readonly unknown[]> = {
|
|
274
|
-
[K in keyof Outputs]: Refinement<RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>], Outputs[K] & RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>]>;
|
|
275
|
-
};
|
|
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>]>; };
|
|
276
249
|
/** Returns the last tuple member, or a fallback for an empty tuple. */
|
|
277
|
-
type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
] ? Tail : Default;
|
|
281
|
-
|
|
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
|
|
282
253
|
/**
|
|
283
254
|
* Combines a precondition refinement with an additional refinement.
|
|
284
255
|
* Prefer this over hand-written `precondition(x) && condition(x)` when the
|
|
@@ -294,8 +265,8 @@ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
|
|
|
294
265
|
* );
|
|
295
266
|
* @see andAll
|
|
296
267
|
*/
|
|
297
|
-
declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
|
|
298
|
-
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<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>;
|
|
299
270
|
/**
|
|
300
271
|
* Chains refinements while preserving the precondition's input domain.
|
|
301
272
|
* Use this instead of nested `&&` checks when each step should keep narrowing
|
|
@@ -309,17 +280,17 @@ declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>
|
|
|
309
280
|
* const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
|
|
310
281
|
* @see and
|
|
311
282
|
*/
|
|
312
|
-
declare function andAll<A>(precondition: Guard<A>): Guard<A>;
|
|
313
|
-
declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
|
|
314
|
-
declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
|
|
315
|
-
declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
|
|
316
|
-
declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
|
|
317
|
-
declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
|
|
318
|
-
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>;
|
|
319
|
-
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>>;
|
|
320
|
-
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>>;
|
|
321
|
-
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>>;
|
|
322
|
-
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<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>>;
|
|
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>;
|
|
323
294
|
/**
|
|
324
295
|
* Logical OR over refinements sharing an input domain.
|
|
325
296
|
* Prefer this over hand-written `refineA(x) || refineB(x)` when the composed
|
|
@@ -331,15 +302,15 @@ declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps
|
|
|
331
302
|
* const isId = or(isString, isNumber);
|
|
332
303
|
* @see oneOf
|
|
333
304
|
*/
|
|
334
|
-
declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
|
|
335
|
-
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<unknown>[]>(...guards: P): Guard<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]>>;
|
|
336
307
|
/**
|
|
337
308
|
* Adapts a guard so it can be used as a refinement within a known supertype.
|
|
338
309
|
*
|
|
339
310
|
* @returns Function that converts a `Guard<T>` into a `Refine<A, T>` when `T extends A`.
|
|
340
311
|
* @see and
|
|
341
312
|
*/
|
|
342
|
-
declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
|
|
313
|
+
export declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
|
|
343
314
|
/**
|
|
344
315
|
* Logical negation of a guard/refinement.
|
|
345
316
|
* Use this when a negated predicate should be named and reused.
|
|
@@ -349,9 +320,10 @@ declare function guardIn<A>(): <T extends A>(guard: Guard<T>) => Refine<A, T>;
|
|
|
349
320
|
* @example
|
|
350
321
|
* const isPresent = not(isNil);
|
|
351
322
|
*/
|
|
352
|
-
declare function not<A, T>(guard: Guard<T>): Refine<A, Exclude<A, Extract<A, T>>>;
|
|
353
|
-
declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A, B>>;
|
|
354
|
-
|
|
323
|
+
export declare function not<A, T>(guard: Guard<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
|
|
355
327
|
/**
|
|
356
328
|
* Allows `null` in addition to values accepted by the given guard/refinement.
|
|
357
329
|
* Use this instead of hand-writing `value === null || guard(value)` when the
|
|
@@ -363,8 +335,8 @@ declare function not<A, B extends A>(refine: Refine<A, B>): Refine<A, Exclude<A,
|
|
|
363
335
|
* const isNullableString = nullable(isString);
|
|
364
336
|
* @see nullish
|
|
365
337
|
*/
|
|
366
|
-
declare function nullable<T>(guard: Guard<T>): Guard<T | null>;
|
|
367
|
-
declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
|
|
338
|
+
export declare function nullable<T>(guard: Guard<T>): Guard<T | null>;
|
|
339
|
+
export declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null, B | null>;
|
|
368
340
|
/**
|
|
369
341
|
* Excludes `null` from the accepted values.
|
|
370
342
|
*
|
|
@@ -373,8 +345,8 @@ declare function nullable<A, B extends A>(refine: Refine<A, B>): Refine<A | null
|
|
|
373
345
|
* @example
|
|
374
346
|
* const isNonNullString = nonNull(nullable(isString));
|
|
375
347
|
*/
|
|
376
|
-
declare function nonNull<T>(guard: Guard<T>): Guard<Exclude<T, null>>;
|
|
377
|
-
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<T>): Guard<Exclude<T, null>>;
|
|
349
|
+
export declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A, null>, Exclude<B, null>>;
|
|
378
350
|
/**
|
|
379
351
|
* Allows `null` or `undefined` in addition to values accepted by the guard.
|
|
380
352
|
* Use this instead of hand-writing `isNil(value) || guard(value)` when widening
|
|
@@ -386,8 +358,8 @@ declare function nonNull<A, B extends A>(refine: Refine<A, B>): Refine<Exclude<A
|
|
|
386
358
|
* const isNullishString = nullish(isString);
|
|
387
359
|
* @see isNil
|
|
388
360
|
*/
|
|
389
|
-
declare function nullish<T>(guard: Guard<T>): Guard<T | null | undefined>;
|
|
390
|
-
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<T>): Guard<T | null | undefined>;
|
|
362
|
+
export declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null | undefined, B | null | undefined>;
|
|
391
363
|
/**
|
|
392
364
|
* Allows `undefined` in addition to values accepted by the guard.
|
|
393
365
|
* Use this for value-level optionality. For optional object keys in `struct`,
|
|
@@ -398,8 +370,8 @@ declare function nullish<A, B extends A>(refine: Refine<A, B>): Refine<A | null
|
|
|
398
370
|
* @example
|
|
399
371
|
* const isOptionalString = optional(isString);
|
|
400
372
|
*/
|
|
401
|
-
declare function optional<T>(guard: Guard<T>): Guard<T | undefined>;
|
|
402
|
-
declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
|
|
373
|
+
export declare function optional<T>(guard: Guard<T>): Guard<T | undefined>;
|
|
374
|
+
export declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | undefined, B | undefined>;
|
|
403
375
|
/**
|
|
404
376
|
* Requires a value to be present (excludes `undefined`).
|
|
405
377
|
*
|
|
@@ -408,9 +380,10 @@ declare function optional<A, B extends A>(refine: Refine<A, B>): Refine<A | unde
|
|
|
408
380
|
* @example
|
|
409
381
|
* const isRequiredString = required(optional(isString));
|
|
410
382
|
*/
|
|
411
|
-
declare function required<T>(guard: Guard<T | undefined>): Guard<T>;
|
|
412
|
-
declare function required<A, B extends A>(refine: Refine<A | undefined, B | undefined>): Refine<A, B>;
|
|
413
|
-
|
|
383
|
+
export declare function required<T>(guard: Guard<T | undefined>): Guard<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
|
|
414
387
|
/**
|
|
415
388
|
* Executes a guard or refinement and returns a tagged result with the value when valid.
|
|
416
389
|
*
|
|
@@ -418,17 +391,17 @@ declare function required<A, B extends A>(refine: Refine<A | undefined, B | unde
|
|
|
418
391
|
* @param value Value to check.
|
|
419
392
|
* @returns `{ valid: true, value }` when the guard passes; `{ valid: false }` otherwise.
|
|
420
393
|
*/
|
|
421
|
-
declare function safeParse<T>(guard: Guard<T>, value: unknown): ParseResult<T>;
|
|
422
|
-
declare function safeParse<A, B extends A>(refine: Refine<A, B>, value: A): ParseResult<B>;
|
|
423
|
-
declare function safeParse(fn: (value: unknown) => boolean, value: unknown): ParseResult<unknown>;
|
|
394
|
+
export declare function safeParse<T>(guard: Guard<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>;
|
|
424
397
|
/**
|
|
425
398
|
* Curried variant of `safeParse` for reuse.
|
|
426
399
|
*
|
|
427
400
|
* @param guard Guard/refinement to evaluate.
|
|
428
401
|
* @returns Function that takes a value and returns the `ParseResult`.
|
|
429
402
|
*/
|
|
430
|
-
declare function safeParseWith<T>(guard: Guard<T>): (value: unknown) => ParseResult<T>;
|
|
431
|
-
declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
|
|
403
|
+
export declare function safeParseWith<T>(guard: Guard<T>): (value: unknown) => ParseResult<T>;
|
|
404
|
+
export declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A) => ParseResult<B>;
|
|
432
405
|
/**
|
|
433
406
|
* Decodes JSON text and validates the decoded value without coercion.
|
|
434
407
|
*
|
|
@@ -436,72 +409,74 @@ declare function safeParseWith<A, B extends A>(refine: Refine<A, B>): (value: A)
|
|
|
436
409
|
* @param guard Guard used to validate the decoded `unknown` value.
|
|
437
410
|
* @returns The decoded value when valid; `{ valid: false }` for invalid JSON or a guard mismatch.
|
|
438
411
|
*/
|
|
439
|
-
declare function safeJsonParse<T>(input: string, guard: Predicate<T>): ParseResult<T>;
|
|
440
|
-
|
|
412
|
+
export declare function safeJsonParse<T>(input: string, guard: Predicate<T>): ParseResult<T>;
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/core/predicate.d.ts
|
|
441
415
|
/**
|
|
442
416
|
* Converts a boolean predicate into a refinement preserving the input type.
|
|
443
417
|
*
|
|
444
418
|
* @param fn Boolean-returning function over a value of type A.
|
|
445
419
|
* @returns Refinement equivalent to the provided predicate.
|
|
446
420
|
*/
|
|
447
|
-
declare const predicateToRefine: <A>(fn: (value: A) => boolean) => Refine<A, A>;
|
|
448
|
-
|
|
421
|
+
export declare const predicateToRefine: <A>(fn: (value: A) => boolean) => Refine<A, A>;
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/core/primitive.d.ts
|
|
449
424
|
/**
|
|
450
425
|
* Checks whether a value is a string.
|
|
451
426
|
*
|
|
452
427
|
* @returns Predicate narrowing to `string`.
|
|
453
428
|
*/
|
|
454
|
-
declare const isString: Predicate<string>;
|
|
429
|
+
export declare const isString: Predicate<string>;
|
|
455
430
|
/**
|
|
456
431
|
* Checks whether a value is a number primitive (may include NaN/±Infinity).
|
|
457
432
|
*
|
|
458
433
|
* @returns Predicate narrowing to `number` (primitive-only).
|
|
459
434
|
*/
|
|
460
|
-
declare const isNumberPrimitive: Predicate<number>;
|
|
435
|
+
export declare const isNumberPrimitive: Predicate<number>;
|
|
461
436
|
/**
|
|
462
437
|
* Checks whether a value is `NaN`.
|
|
463
438
|
*
|
|
464
439
|
* Equivalent to `Number.isNaN(value)` without coercion.
|
|
465
440
|
* @returns Predicate narrowing to `number` (`NaN` only).
|
|
466
441
|
*/
|
|
467
|
-
declare const isNaN: Predicate<number>;
|
|
442
|
+
export declare const isNaN: Predicate<number>;
|
|
468
443
|
/**
|
|
469
444
|
* Checks whether a value is an infinite number (±Infinity).
|
|
470
445
|
*
|
|
471
446
|
* @returns Predicate narrowing to `number` (Infinity or -Infinity).
|
|
472
447
|
*/
|
|
473
|
-
declare const isInfiniteNumber: Predicate<number>;
|
|
448
|
+
export declare const isInfiniteNumber: Predicate<number>;
|
|
474
449
|
/**
|
|
475
450
|
* Checks whether a number is finite.
|
|
476
451
|
* @returns Refinement that accepts only finite numbers.
|
|
477
452
|
*/
|
|
478
|
-
declare const isFiniteNumber: Refine<number, number>;
|
|
453
|
+
export declare const isFiniteNumber: Refine<number, number>;
|
|
479
454
|
/**
|
|
480
455
|
* Checks whether a value is a finite number.
|
|
481
456
|
* @returns Predicate narrowing to finite `number`.
|
|
482
457
|
*/
|
|
483
|
-
declare const isNumber: Predicate<number>;
|
|
458
|
+
export declare const isNumber: Predicate<number>;
|
|
484
459
|
/**
|
|
485
460
|
* Checks whether a value is an integer number.
|
|
486
461
|
*
|
|
487
462
|
* Equivalent to `Number.isInteger(value)`.
|
|
488
463
|
* @returns Predicate narrowing to integer `number`.
|
|
489
464
|
*/
|
|
490
|
-
declare const isInteger: Predicate<number>;
|
|
465
|
+
export declare const isInteger: Predicate<number>;
|
|
491
466
|
/**
|
|
492
467
|
* Checks whether a value is a safe integer.
|
|
493
468
|
*
|
|
494
469
|
* Equivalent to `Number.isSafeInteger(value)`.
|
|
495
470
|
* @returns Predicate narrowing to safe-integer `number`.
|
|
496
471
|
*/
|
|
497
|
-
declare const isSafeInteger: Predicate<number>;
|
|
472
|
+
export declare const isSafeInteger: Predicate<number>;
|
|
498
473
|
/**
|
|
499
474
|
* Checks whether a value is a positive finite number (> 0).
|
|
500
475
|
*
|
|
501
476
|
* Uses `isNumber` internally to exclude NaN and ±Infinity.
|
|
502
477
|
* @returns Predicate narrowing to positive `number`.
|
|
503
478
|
*/
|
|
504
|
-
declare const isPositive: Predicate<number>;
|
|
479
|
+
export declare const isPositive: Predicate<number>;
|
|
505
480
|
/**
|
|
506
481
|
* Checks whether a value is a negative finite number (< 0).
|
|
507
482
|
*
|
|
@@ -509,31 +484,31 @@ declare const isPositive: Predicate<number>;
|
|
|
509
484
|
* Note: `-0` is not considered negative (consistent with `< 0`).
|
|
510
485
|
* @returns Predicate narrowing to negative `number`.
|
|
511
486
|
*/
|
|
512
|
-
declare const isNegative: Predicate<number>;
|
|
487
|
+
export declare const isNegative: Predicate<number>;
|
|
513
488
|
/**
|
|
514
489
|
* Checks whether a value is a finite number that equals zero (including `-0`).
|
|
515
490
|
*
|
|
516
491
|
* @returns Predicate narrowing to zero `number`.
|
|
517
492
|
*/
|
|
518
|
-
declare const isZero: Predicate<number>;
|
|
493
|
+
export declare const isZero: Predicate<number>;
|
|
519
494
|
/**
|
|
520
495
|
* Checks whether a value is a boolean.
|
|
521
496
|
*
|
|
522
497
|
* @returns Predicate narrowing to `boolean`.
|
|
523
498
|
*/
|
|
524
|
-
declare const isBoolean: Predicate<boolean>;
|
|
499
|
+
export declare const isBoolean: Predicate<boolean>;
|
|
525
500
|
/**
|
|
526
501
|
* Checks whether a value is a bigint.
|
|
527
502
|
*
|
|
528
503
|
* @returns Predicate narrowing to `bigint`.
|
|
529
504
|
*/
|
|
530
|
-
declare const isBigInt: Predicate<bigint>;
|
|
505
|
+
export declare const isBigInt: Predicate<bigint>;
|
|
531
506
|
/**
|
|
532
507
|
* Checks whether a value is a symbol.
|
|
533
508
|
*
|
|
534
509
|
* @returns Predicate narrowing to `symbol`.
|
|
535
510
|
*/
|
|
536
|
-
declare const isSymbol: Predicate<symbol>;
|
|
511
|
+
export declare const isSymbol: Predicate<symbol>;
|
|
537
512
|
/**
|
|
538
513
|
* Checks whether a value is exactly `undefined`.
|
|
539
514
|
*
|
|
@@ -543,7 +518,7 @@ declare const isSymbol: Predicate<symbol>;
|
|
|
543
518
|
* @returns Predicate narrowing to `undefined`.
|
|
544
519
|
* @see isNil
|
|
545
520
|
*/
|
|
546
|
-
declare const isUndefined: Predicate<undefined>;
|
|
521
|
+
export declare const isUndefined: Predicate<undefined>;
|
|
547
522
|
/**
|
|
548
523
|
* Checks whether a value is exactly `null`.
|
|
549
524
|
*
|
|
@@ -553,7 +528,7 @@ declare const isUndefined: Predicate<undefined>;
|
|
|
553
528
|
* @returns Predicate narrowing to `null`.
|
|
554
529
|
* @see isNil
|
|
555
530
|
*/
|
|
556
|
-
declare const isNull: Predicate<null>;
|
|
531
|
+
export declare const isNull: Predicate<null>;
|
|
557
532
|
/**
|
|
558
533
|
* Checks whether a value is `null` or `undefined` (nullish).
|
|
559
534
|
*
|
|
@@ -567,7 +542,7 @@ declare const isNull: Predicate<null>;
|
|
|
567
542
|
* isNil(undefined); // true
|
|
568
543
|
* isNil(0); // false
|
|
569
544
|
*/
|
|
570
|
-
declare const isNil: (value: unknown) => value is null | undefined;
|
|
545
|
+
export declare const isNil: (value: unknown) => value is null | undefined;
|
|
571
546
|
/**
|
|
572
547
|
* Checks whether a value is neither `null` nor `undefined`.
|
|
573
548
|
*
|
|
@@ -581,7 +556,7 @@ declare const isNil: (value: unknown) => value is null | undefined;
|
|
|
581
556
|
* const presentValues = values.filter(isNotNil); // string[]
|
|
582
557
|
* @see isNil
|
|
583
558
|
*/
|
|
584
|
-
declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
|
|
559
|
+
export declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
|
|
585
560
|
/**
|
|
586
561
|
* Checks whether a value is a JavaScript primitive.
|
|
587
562
|
*
|
|
@@ -590,152 +565,155 @@ declare const isNotNil: <T>(value: T) => value is NonNullable<T>;
|
|
|
590
565
|
*
|
|
591
566
|
* @returns Predicate narrowing to `Primitive`.
|
|
592
567
|
*/
|
|
593
|
-
declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
594
|
-
|
|
568
|
+
export declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region src/core/object.d.ts
|
|
595
571
|
type AnyFunction = (...args: never[]) => unknown;
|
|
596
572
|
/**
|
|
597
573
|
* Checks whether a value is a function.
|
|
598
574
|
*
|
|
599
575
|
* @returns Predicate narrowing to a callable value.
|
|
600
576
|
*/
|
|
601
|
-
declare const isFunction: Predicate<AnyFunction>;
|
|
577
|
+
export declare const isFunction: Predicate<AnyFunction>;
|
|
602
578
|
/**
|
|
603
579
|
* Checks for non-null objects (including arrays, dates, etc.).
|
|
604
580
|
*
|
|
605
581
|
* @returns Predicate narrowing to `Record<PropertyKey, unknown>`.
|
|
606
582
|
*/
|
|
607
|
-
declare const isObject: Predicate<Record<PropertyKey, unknown>>;
|
|
583
|
+
export declare const isObject: Predicate<Record<PropertyKey, unknown>>;
|
|
608
584
|
/**
|
|
609
585
|
* Checks for plain objects created by object literals or `Object.create(null)`.
|
|
610
586
|
*
|
|
611
587
|
* @returns Predicate narrowing to `Record<string, unknown>`.
|
|
612
588
|
*/
|
|
613
|
-
declare const isPlainObject: Predicate<Record<string, unknown>>;
|
|
589
|
+
export declare const isPlainObject: Predicate<Record<string, unknown>>;
|
|
614
590
|
/**
|
|
615
591
|
* Checks whether a value is an array.
|
|
616
592
|
*
|
|
617
593
|
* @returns Predicate narrowing to `readonly unknown[]`.
|
|
618
594
|
*/
|
|
619
|
-
declare const isArray: Predicate<readonly unknown[]>;
|
|
595
|
+
export declare const isArray: Predicate<readonly unknown[]>;
|
|
620
596
|
/**
|
|
621
597
|
* Checks whether a value is a valid `Date` instance (not `Invalid Date`).
|
|
622
598
|
*
|
|
623
599
|
* @returns Predicate narrowing to `Date`.
|
|
624
600
|
*/
|
|
625
|
-
declare const isDate: Predicate<Date>;
|
|
601
|
+
export declare const isDate: Predicate<Date>;
|
|
626
602
|
/**
|
|
627
603
|
* Checks whether a value is a `RegExp`.
|
|
628
604
|
*
|
|
629
605
|
* @returns Predicate narrowing to `RegExp`.
|
|
630
606
|
*/
|
|
631
|
-
declare const isRegExp: Guard<RegExp>;
|
|
607
|
+
export declare const isRegExp: Guard<RegExp>;
|
|
632
608
|
/**
|
|
633
609
|
* Checks whether a value is a `Map`.
|
|
634
610
|
*
|
|
635
611
|
* @returns Predicate narrowing to `Map<unknown, unknown>`.
|
|
636
612
|
*/
|
|
637
|
-
declare const isMap: Guard<Map<unknown, unknown>>;
|
|
613
|
+
export declare const isMap: Guard<Map<unknown, unknown>>;
|
|
638
614
|
/**
|
|
639
615
|
* Checks whether a value is a `Set`.
|
|
640
616
|
*
|
|
641
617
|
* @returns Predicate narrowing to `Set<unknown>`.
|
|
642
618
|
*/
|
|
643
|
-
declare const isSet: Guard<Set<unknown>>;
|
|
619
|
+
export declare const isSet: Guard<Set<unknown>>;
|
|
644
620
|
/**
|
|
645
621
|
* Checks whether a value is a `WeakMap`.
|
|
646
622
|
*
|
|
647
623
|
* @returns Predicate narrowing to `WeakMap<object, unknown>`.
|
|
648
624
|
*/
|
|
649
|
-
declare const isWeakMap: Guard<WeakMap<object, unknown>>;
|
|
625
|
+
export declare const isWeakMap: Guard<WeakMap<object, unknown>>;
|
|
650
626
|
/**
|
|
651
627
|
* Checks whether a value is a `WeakSet`.
|
|
652
628
|
*
|
|
653
629
|
* @returns Predicate narrowing to `WeakSet<object>`.
|
|
654
630
|
*/
|
|
655
|
-
declare const isWeakSet: Guard<WeakSet<object>>;
|
|
631
|
+
export declare const isWeakSet: Guard<WeakSet<object>>;
|
|
656
632
|
/**
|
|
657
633
|
* Checks whether a value is promise-like (has a `then` function).
|
|
658
634
|
*
|
|
659
635
|
* @returns Predicate narrowing to `PromiseLike<unknown>`.
|
|
660
636
|
*/
|
|
661
|
-
declare const isPromiseLike: Predicate<PromiseLike<unknown>>;
|
|
637
|
+
export declare const isPromiseLike: Predicate<PromiseLike<unknown>>;
|
|
662
638
|
/**
|
|
663
639
|
* Checks whether a value implements the `Iterable` protocol.
|
|
664
640
|
*
|
|
665
641
|
* @returns Predicate narrowing to `Iterable<unknown>`.
|
|
666
642
|
*/
|
|
667
|
-
declare const isIterable: Predicate<Iterable<unknown>>;
|
|
643
|
+
export declare const isIterable: Predicate<Iterable<unknown>>;
|
|
668
644
|
/**
|
|
669
645
|
* Checks whether a value implements the `AsyncIterable` protocol.
|
|
670
646
|
*
|
|
671
647
|
* @returns Predicate narrowing to `AsyncIterable<unknown>`.
|
|
672
648
|
*/
|
|
673
|
-
declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
|
|
649
|
+
export declare const isAsyncIterable: Predicate<AsyncIterable<unknown>>;
|
|
674
650
|
/**
|
|
675
651
|
* Checks whether a value is an `ArrayBuffer`.
|
|
676
652
|
*
|
|
677
653
|
* @returns Predicate narrowing to `ArrayBuffer`.
|
|
678
654
|
*/
|
|
679
|
-
declare const isArrayBuffer: Guard<ArrayBuffer>;
|
|
655
|
+
export declare const isArrayBuffer: Guard<ArrayBuffer>;
|
|
680
656
|
/**
|
|
681
657
|
* Checks whether a value is a `DataView`.
|
|
682
658
|
*
|
|
683
659
|
* @returns Predicate narrowing to `DataView`.
|
|
684
660
|
*/
|
|
685
|
-
declare const isDataView: Guard<DataView<ArrayBufferLike>>;
|
|
661
|
+
export declare const isDataView: Guard<DataView<ArrayBufferLike>>;
|
|
686
662
|
/**
|
|
687
663
|
* Checks whether a value is a typed array view (any `ArrayBufferView` except DataView).
|
|
688
664
|
*
|
|
689
665
|
* @returns Predicate narrowing to `ArrayBufferView`.
|
|
690
666
|
*/
|
|
691
|
-
declare const isTypedArray: Predicate<ArrayBufferView<ArrayBufferLike>>;
|
|
667
|
+
export declare const isTypedArray: Predicate<ArrayBufferView<ArrayBufferLike>>;
|
|
692
668
|
/**
|
|
693
669
|
* Checks whether a value is an `Error` (instance of Error or plain Error object tag).
|
|
694
670
|
*
|
|
695
671
|
* @returns Predicate narrowing to `Error`.
|
|
696
672
|
*/
|
|
697
|
-
declare const isError: Predicate<Error>;
|
|
673
|
+
export declare const isError: Predicate<Error>;
|
|
698
674
|
/**
|
|
699
675
|
* Checks whether a value is a `URL` (in environments with URL available).
|
|
700
676
|
*
|
|
701
677
|
* @returns Predicate narrowing to `URL` when supported; otherwise always false.
|
|
702
678
|
*/
|
|
703
|
-
declare const isURL: Guard<URL>;
|
|
679
|
+
export declare const isURL: Guard<URL>;
|
|
704
680
|
/**
|
|
705
681
|
* Checks whether a value is a `Blob` (in environments with Blob available).
|
|
706
682
|
*
|
|
707
683
|
* @returns Predicate narrowing to `Blob` when supported; otherwise always false.
|
|
708
684
|
*/
|
|
709
|
-
declare const isBlob: Guard<Blob>;
|
|
685
|
+
export declare const isBlob: Guard<Blob>;
|
|
710
686
|
/**
|
|
711
687
|
* Checks whether a value is a `File` (in environments with File available).
|
|
712
688
|
*
|
|
713
689
|
* @returns Predicate narrowing to `File` when supported; otherwise always false.
|
|
714
690
|
*/
|
|
715
|
-
declare const isFile: Guard<File>;
|
|
691
|
+
export declare const isFile: Guard<File>;
|
|
716
692
|
/**
|
|
717
693
|
* Creates a guard that checks whether a value is an instance of `constructor`.
|
|
718
694
|
*
|
|
719
695
|
* @param constructor Constructor used as the right-hand side of `instanceof`.
|
|
720
696
|
* @returns Predicate narrowing to `InstanceType<C>`.
|
|
721
697
|
*/
|
|
722
|
-
declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard<InstanceType<C>>;
|
|
723
|
-
|
|
698
|
+
export declare const isInstanceOf: <C extends abstract new (...args: unknown[]) => unknown>(constructor: C) => Guard<InstanceType<C>>;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/core/combinators/array.d.ts
|
|
724
701
|
/**
|
|
725
702
|
* Validates an array where every element satisfies the provided guard.
|
|
726
703
|
*
|
|
727
704
|
* @param elementGuard Guard applied to each array element.
|
|
728
705
|
* @returns Predicate narrowing to a readonly array of the guarded element type.
|
|
729
706
|
*/
|
|
730
|
-
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>[]>;
|
|
731
708
|
/**
|
|
732
709
|
* Validates a non-empty array where every element satisfies the provided guard.
|
|
733
710
|
*
|
|
734
711
|
* @param elementGuard Guard applied to each array element.
|
|
735
712
|
* @returns Predicate narrowing to a readonly non-empty array of the guarded element type.
|
|
736
713
|
*/
|
|
737
|
-
declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
|
|
738
|
-
|
|
714
|
+
export declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F): Predicate<readonly [GuardedOf<F>, ...GuardedOf<F>[]]>;
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/core/combinators/map.d.ts
|
|
739
717
|
/**
|
|
740
718
|
* Validates a map where every key and value satisfies the provided guards.
|
|
741
719
|
*
|
|
@@ -743,18 +721,20 @@ declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F):
|
|
|
743
721
|
* @param valueGuard Guard applied to each map value.
|
|
744
722
|
* @returns Predicate narrowing to a readonly map with guarded key/value types.
|
|
745
723
|
*/
|
|
746
|
-
declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
|
|
747
|
-
|
|
724
|
+
export declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/core/combinators/one-of.d.ts
|
|
748
727
|
/**
|
|
749
728
|
* Combines refinements sharing an input domain.
|
|
750
729
|
*
|
|
751
730
|
* @param refinements One or more refinements to try.
|
|
752
731
|
* @returns Refinement that narrows to the union of matching types.
|
|
753
732
|
*/
|
|
754
|
-
declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
|
|
755
|
-
declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
|
|
756
|
-
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]>>;
|
|
757
|
-
|
|
733
|
+
export declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
|
|
734
|
+
export declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
|
|
735
|
+
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]>>;
|
|
736
|
+
//#endregion
|
|
737
|
+
//#region src/core/combinators/one-of-values.d.ts
|
|
758
738
|
/**
|
|
759
739
|
* Creates a guard that matches when the input is one of the provided literal values.
|
|
760
740
|
* Uses `Object.is` for exact value semantics. For large sets, keeps O(1) lookups while
|
|
@@ -763,10 +743,11 @@ declare function oneOf<A, B extends A, Rest extends readonly Refinement<A, A>[]>
|
|
|
763
743
|
* @param values Literal primitives to compare against (varargs or single readonly tuple array).
|
|
764
744
|
* @returns Predicate narrowing to the union of the provided literal values.
|
|
765
745
|
*/
|
|
766
|
-
declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values: T): Predicate<T[number]>;
|
|
767
|
-
declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(values: T): Predicate<T[number]>;
|
|
768
|
-
declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...valuesOrArray: T | [T]): Predicate<T[number]>;
|
|
769
|
-
|
|
746
|
+
export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values: T): Predicate<T[number]>;
|
|
747
|
+
export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(values: T): Predicate<T[number]>;
|
|
748
|
+
export declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...valuesOrArray: T | [T]): Predicate<T[number]>;
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/core/combinators/record.d.ts
|
|
770
751
|
/**
|
|
771
752
|
* Validates a record-like object by guarding both keys and values.
|
|
772
753
|
*
|
|
@@ -774,16 +755,18 @@ declare function oneOfValues<const T extends ReadonlyArray<Primitive>>(...values
|
|
|
774
755
|
* @param valueFunction Guard applied to each value in the record.
|
|
775
756
|
* @returns Predicate narrowing to a readonly record with guarded key/value types.
|
|
776
757
|
*/
|
|
777
|
-
declare function recordOf<KF extends Predicate<string>, VF extends Predicate<unknown>>(keyFunction: KF, valueFunction: VF): Predicate<Readonly<Record<GuardedOf<KF>, GuardedOf<VF>>>>;
|
|
778
|
-
|
|
758
|
+
export declare function recordOf<KF extends Predicate<string>, VF extends Predicate<unknown>>(keyFunction: KF, valueFunction: VF): Predicate<Readonly<Record<GuardedOf<KF>, GuardedOf<VF>>>>;
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/core/combinators/set.d.ts
|
|
779
761
|
/**
|
|
780
762
|
* Validates a set where every value satisfies the provided guard.
|
|
781
763
|
*
|
|
782
764
|
* @param valueGuard Guard applied to each set value.
|
|
783
765
|
* @returns Predicate narrowing to a readonly set of the guarded value type.
|
|
784
766
|
*/
|
|
785
|
-
declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate<ReadonlySet<GuardedOf<VF>>>;
|
|
786
|
-
|
|
767
|
+
export declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate<ReadonlySet<GuardedOf<VF>>>;
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region src/core/combinators/struct.d.ts
|
|
787
770
|
/**
|
|
788
771
|
* Marks a struct schema field as optional at the key level.
|
|
789
772
|
*
|
|
@@ -793,7 +776,7 @@ declare function setOf<VF extends Predicate<unknown>>(valueGuard: VF): Predicate
|
|
|
793
776
|
* @param guard Guard used to validate the property value when the key exists.
|
|
794
777
|
* @returns Schema field marker understood by `struct`.
|
|
795
778
|
*/
|
|
796
|
-
declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSchemaField<G>;
|
|
779
|
+
export declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSchemaField<G>;
|
|
797
780
|
/**
|
|
798
781
|
* Validates an object against a field-to-guard schema.
|
|
799
782
|
* Keys in the schema are required unless wrapped with `optionalKey`; optionally
|
|
@@ -804,8 +787,9 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
|
|
|
804
787
|
* properties not in `schema`.
|
|
805
788
|
* @returns Predicate that narrows to the inferred struct type.
|
|
806
789
|
*/
|
|
807
|
-
declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
|
|
808
|
-
|
|
790
|
+
export declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/core/combinators/typed-struct.d.ts
|
|
809
793
|
/**
|
|
810
794
|
* Creates a `struct` builder checked against an existing string-keyed object
|
|
811
795
|
* type. Numeric and symbol properties are excluded from the checked shape and
|
|
@@ -818,18 +802,18 @@ declare function struct<const S extends SchemaShape<S>>(schema: S, options?: Str
|
|
|
818
802
|
*
|
|
819
803
|
* @returns Builder that rejects missing, extra, or incompatible struct fields.
|
|
820
804
|
*/
|
|
821
|
-
declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
822
|
-
|
|
805
|
+
export declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/core/combinators/tuple.d.ts
|
|
823
808
|
/**
|
|
824
809
|
* Validates a fixed-length tuple by applying element-wise guards.
|
|
825
810
|
*
|
|
826
811
|
* @param guards Guards corresponding to each tuple position.
|
|
827
812
|
* @returns Predicate that narrows to a readonly tuple of guarded element types.
|
|
828
813
|
*/
|
|
829
|
-
declare function tupleOf<const Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<{
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
814
|
+
export declare function tupleOf<const Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<{ readonly [K in keyof Fs]: GuardedOf<Fs[K]>; }>;
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/utils/guard-collections.d.ts
|
|
833
817
|
type BooleanPredicate<T> = (value: T) => boolean;
|
|
834
818
|
/**
|
|
835
819
|
* Checks whether every array element satisfies the provided predicate.
|
|
@@ -840,7 +824,7 @@ type BooleanPredicate<T> = (value: T) => boolean;
|
|
|
840
824
|
* @param predicate Predicate applied to each element.
|
|
841
825
|
* @returns Whether all elements satisfy `predicate`.
|
|
842
826
|
*/
|
|
843
|
-
declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPredicate<unknown>) => boolean;
|
|
827
|
+
export declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPredicate<unknown>) => boolean;
|
|
844
828
|
/**
|
|
845
829
|
* Checks whether a tuple matches the provided element predicates in order.
|
|
846
830
|
*
|
|
@@ -850,7 +834,7 @@ declare const everyArrayValue: (values: readonly unknown[], predicate: BooleanPr
|
|
|
850
834
|
* @param predicates Predicates aligned to each tuple index.
|
|
851
835
|
* @returns Whether lengths match and each index passes.
|
|
852
836
|
*/
|
|
853
|
-
declare const everyTupleValue: (values: readonly unknown[], predicates: readonly BooleanPredicate<unknown>[]) => boolean;
|
|
837
|
+
export declare const everyTupleValue: (values: readonly unknown[], predicates: readonly BooleanPredicate<unknown>[]) => boolean;
|
|
854
838
|
/**
|
|
855
839
|
* Checks whether every set value satisfies the provided predicate.
|
|
856
840
|
*
|
|
@@ -860,7 +844,7 @@ declare const everyTupleValue: (values: readonly unknown[], predicates: readonly
|
|
|
860
844
|
* @param predicate Predicate applied to each value.
|
|
861
845
|
* @returns Whether all set values satisfy `predicate`.
|
|
862
846
|
*/
|
|
863
|
-
declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPredicate<unknown>) => boolean;
|
|
847
|
+
export declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPredicate<unknown>) => boolean;
|
|
864
848
|
/**
|
|
865
849
|
* Checks whether every map entry satisfies the provided key and value predicates.
|
|
866
850
|
*
|
|
@@ -871,7 +855,7 @@ declare const everySetValue: (values: ReadonlySet<unknown>, predicate: BooleanPr
|
|
|
871
855
|
* @param valuePredicate Predicate applied to each value.
|
|
872
856
|
* @returns Whether all keys and values satisfy their predicates.
|
|
873
857
|
*/
|
|
874
|
-
declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicate: BooleanPredicate<unknown>, valuePredicate: BooleanPredicate<unknown>) => boolean;
|
|
858
|
+
export declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicate: BooleanPredicate<unknown>, valuePredicate: BooleanPredicate<unknown>) => boolean;
|
|
875
859
|
/**
|
|
876
860
|
* Checks whether every own enumerable string key/value pair satisfies the provided predicates.
|
|
877
861
|
*
|
|
@@ -883,8 +867,9 @@ declare const everyMapEntry: (values: ReadonlyMap<unknown, unknown>, keyPredicat
|
|
|
883
867
|
* @param valuePredicate Predicate applied to each corresponding value.
|
|
884
868
|
* @returns Whether all enumerable entries satisfy their predicates.
|
|
885
869
|
*/
|
|
886
|
-
declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPredicate: BooleanPredicate<string>, valuePredicate: BooleanPredicate<unknown>) => boolean;
|
|
887
|
-
|
|
870
|
+
export declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPredicate: BooleanPredicate<string>, valuePredicate: BooleanPredicate<unknown>) => boolean;
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/utils/to-boolean-predicates.d.ts
|
|
888
873
|
/**
|
|
889
874
|
* Converts predicates to plain boolean predicates for iteration helpers.
|
|
890
875
|
*
|
|
@@ -893,6 +878,6 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
|
|
|
893
878
|
* @param predicates Predicates to be treated as simple boolean functions.
|
|
894
879
|
* @returns Readonly array of boolean-returning functions.
|
|
895
880
|
*/
|
|
896
|
-
declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
897
|
-
|
|
898
|
-
export {
|
|
881
|
+
export declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
882
|
+
//#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 };
|