is-kit 1.12.0 โ†’ 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,8 @@
23
23
  </a>
24
24
  </p>
25
25
 
26
+ <h2 align="center">Build small guards. Compose them.</h2>
27
+
26
28
  `is-kit` is a lightweight, zero-dependency toolkit for building reusable TypeScript **type guards**.
27
29
 
28
30
  It helps you write small `isFoo` functions, compose them into **richer runtime checks**, and keep **TypeScript narrowing** natural inside regular control flow.
@@ -34,7 +36,8 @@ It helps you write small `isFoo` functions, compose them into **richer runtime c
34
36
  - **Validate object** shapes and collections
35
37
  - **Parse or assert** `unknown` values without a large schema framework
36
38
 
37
- [๐Ÿ“š Documentation Site](https://is-kit-docs.vercel.app/)
39
+ [๐Ÿ“š Documentation Site](https://is-kit.dev/) ยท
40
+ [๐Ÿงญ Practical Guides](https://is-kit.dev/guides)
38
41
 
39
42
  > Best for **app-internal narrowing, filtering, and reusable guards**.
40
43
 
@@ -71,12 +74,25 @@ bun add is-kit
71
74
  npm install is-kit
72
75
  # or
73
76
  yarn add is-kit
77
+ # or
78
+ vlt install is-kit
74
79
  ```
75
80
 
76
81
  ESM and CJS builds are available for npm consumers, and bundled types are included.
77
82
 
83
+ vlt requires registry configuration before installing a package by name. Run
84
+ `vlt setup` once if a registry has not been configured yet.
85
+
78
86
  ### JSR
79
87
 
88
+ Install the JSR package with vlt:
89
+
90
+ ```bash
91
+ vlt install jsr:@nyaomaru/is-kit
92
+ ```
93
+
94
+ Or import it directly in runtimes that support `jsr:` specifiers:
95
+
80
96
  ```ts
81
97
  import { and, define, or } from 'jsr:@nyaomaru/is-kit';
82
98
  ```
@@ -505,7 +521,9 @@ if (parsed.valid) {
505
521
  sync with an existing object type. Optional keys in `T` must still be declared
506
522
  with `optionalKey(...)`; this makes drift visible when the target type changes.
507
523
  OpenAPI-generated response types are one useful case, but the helper is not an
508
- OpenAPI validator or schema generator.
524
+ OpenAPI validator or schema generator. Drift detection is limited to
525
+ string-keyed properties; numeric and symbol properties are excluded from the
526
+ checked shape and cannot be validated by the resulting guard.
509
527
 
510
528
  ### Safe array filtering
511
529
 
@@ -583,7 +601,14 @@ public root exports are planned for removal.
583
601
 
584
602
  For detailed API pages and more examples, see:
585
603
 
586
- https://is-kit-docs.vercel.app/
604
+ - [Practical guides](https://is-kit.dev/guides)
605
+ - [Keep hand-written type guards in sync with TypeScript types](https://is-kit.dev/guides/keep-type-guards-in-sync)
606
+ - [Validate unknown without a schema library](https://is-kit.dev/guides/validate-unknown-without-schema-library)
607
+ - [API reference](https://is-kit.dev/api-reference)
608
+ - [Documentation home](https://is-kit.dev/)
609
+
610
+ Start with [How to safely filter null and undefined from arrays in
611
+ TypeScript](https://is-kit.dev/guides/filter-null-and-undefined).
587
612
 
588
613
  ## ๐Ÿ‘จโ€๐Ÿ’ป Development
589
614
 
package/dist/index.d.mts CHANGED
@@ -6,10 +6,10 @@
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
- /** Predicate that accepts an unknown value and narrows it to `T`. */
10
- type Predicate<T> = (value: unknown) => value is T;
11
9
  /** Refinement that narrows a known input type `A` to its subtype `B`. */
12
10
  type Refinement<A, B extends A> = (value: A) => value is B;
11
+ /** Predicate that accepts an unknown value and narrows it to `T`. */
12
+ type Predicate<T> = Refinement<unknown, T>;
13
13
  /** Readability alias for {@link Predicate}. */
14
14
  type Guard<T> = Predicate<T>;
15
15
  /** Readability alias for {@link Refinement}. */
@@ -27,8 +27,8 @@ type ParseResult<T> = {
27
27
  } | {
28
28
  valid: false;
29
29
  };
30
- /** Extracts the narrowed output type from a predicate. */
31
- type GuardedOf<F> = F extends ((value: unknown) => value is infer G) ? G : never;
30
+ /** Extracts the narrowed output type from a predicate or refinement. */
31
+ type GuardedOf<F> = F extends Refinement<infer A, infer B> ? B : never;
32
32
  /** Extracts guard outputs that remain assignable to a known input type. */
33
33
  type GuardedWithin<Fs, A> = Extract<Fs extends readonly unknown[] ? GuardedOf<Fs[number]> : never, A>;
34
34
 
@@ -92,7 +92,8 @@ type OptionalObjectKeys<T> = {
92
92
  */
93
93
  type RequiredObjectKeys<T> = Exclude<keyof T, OptionalObjectKeys<T>>;
94
94
  /**
95
- * Schema shape checked against an existing object type by `typedStruct`.
95
+ * String-keyed schema shape checked against an existing object type by
96
+ * `typedStruct`. Numeric and symbol properties are excluded.
96
97
  */
97
98
  type TypedStructShape<T extends object> = {
98
99
  readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>;
@@ -204,14 +205,28 @@ declare function narrowKeyTo<A, K extends keyof A>(guard: Guard<A>, key: K): <co
204
205
  */
205
206
  declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
206
207
 
208
+ type RefinementInputs<In, Outputs extends readonly unknown[]> = readonly [
209
+ In,
210
+ ...Outputs
211
+ ];
212
+ /** Builds an ordered refinement tuple from its initial input and output tuple. */
213
+ type RefinementsFromOutputs<In, Outputs extends readonly unknown[]> = {
214
+ [K in keyof Outputs]: Refinement<RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>], Outputs[K] & RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>]>;
215
+ };
216
+ /** Returns the last tuple member, or a fallback for an empty tuple. */
217
+ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
218
+ ...unknown[],
219
+ infer Tail
220
+ ] ? Tail : Default;
221
+
207
222
  /**
208
- * Combines a precondition guard with an additional refinement to narrow the type.
223
+ * Combines a precondition refinement with an additional refinement.
209
224
  * Prefer this over hand-written `precondition(x) && condition(x)` when the
210
- * composed predicate should be reused as a guard.
225
+ * composed refinement should be reused.
211
226
  *
212
227
  * @param precondition Broad guard evaluated first; short-circuits on failure.
213
228
  * @param condition Refinement evaluated only when `precondition` passes.
214
- * @returns Predicate that narrows the input to a subtype.
229
+ * @returns Refinement that preserves the precondition's input domain.
215
230
  * @example
216
231
  * const isPositiveNumber = and(
217
232
  * isNumber,
@@ -220,14 +235,16 @@ declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
220
235
  * @see andAll
221
236
  */
222
237
  declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
238
+ declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
223
239
  /**
224
- * Chains a sequence of refinements after a precondition, returning the final guard type.
240
+ * Chains refinements while preserving the precondition's input domain.
225
241
  * Use this instead of nested `&&` checks when each step should keep narrowing
226
242
  * the next refinement.
243
+ * Pass a generic readonly chain as one tuple to preserve its final narrowing.
227
244
  *
228
245
  * @param precondition Initial guard applied first.
229
246
  * @param steps Subsequent refinements applied in order.
230
- * @returns Guard reflecting the result of the refinement chain.
247
+ * @returns Refinement reflecting the final result of the chain.
231
248
  * @example
232
249
  * const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
233
250
  * @see and
@@ -235,18 +252,27 @@ declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A
235
252
  declare function andAll<A>(precondition: Guard<A>): Guard<A>;
236
253
  declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
237
254
  declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
238
- /**
239
- * Logical OR over multiple guards.
240
- * Prefer this over hand-written `guardA(x) || guardB(x)` when the composed
241
- * predicate should be reused as a guard.
242
- *
243
- * @param guards Guards to evaluate; passes if any guard passes.
244
- * @returns Guard for the union of all guarded types.
255
+ declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
256
+ declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
257
+ declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
258
+ 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>;
259
+ 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>>;
260
+ 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>>;
261
+ 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>>;
262
+ declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps: readonly Refine<NoInfer<B>, NoInfer<B>>[]): Refinement<A, B>;
263
+ /**
264
+ * Logical OR over refinements sharing an input domain.
265
+ * Prefer this over hand-written `refineA(x) || refineB(x)` when the composed
266
+ * refinement should be reused.
267
+ *
268
+ * @param refinements Refinements to evaluate; passes if any refinement passes.
269
+ * @returns Refinement for the union of all narrowed types.
245
270
  * @example
246
271
  * const isId = or(isString, isNumber);
247
272
  * @see oneOf
248
273
  */
249
274
  declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
275
+ 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]>>;
250
276
  /**
251
277
  * Adapts a guard so it can be used as a refinement within a known supertype.
252
278
  *
@@ -661,13 +687,14 @@ declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F):
661
687
  declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
662
688
 
663
689
  /**
664
- * Combines multiple guards; passes when any one guard matches.
690
+ * Combines refinements sharing an input domain.
665
691
  *
666
- * @param guards One or more type guards/refinements to try.
667
- * @returns Predicate that narrows to the union of guarded types.
692
+ * @param refinements One or more refinements to try.
693
+ * @returns Refinement that narrows to the union of matching types.
668
694
  */
669
695
  declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
670
696
  declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
697
+ 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]>>;
671
698
 
672
699
  /**
673
700
  * Creates a guard that matches when the input is one of the provided literal values.
@@ -721,7 +748,9 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
721
748
  declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
722
749
 
723
750
  /**
724
- * Creates a `struct` builder checked against an existing object type.
751
+ * Creates a `struct` builder checked against an existing string-keyed object
752
+ * type. Numeric and symbol properties are excluded from the checked shape and
753
+ * cannot be validated by the resulting guard.
725
754
  * Optional target keys must also be declared with `optionalKey` so type drift
726
755
  * stays visible when the target type changes.
727
756
  *
package/dist/index.d.ts CHANGED
@@ -6,10 +6,10 @@
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
- /** Predicate that accepts an unknown value and narrows it to `T`. */
10
- type Predicate<T> = (value: unknown) => value is T;
11
9
  /** Refinement that narrows a known input type `A` to its subtype `B`. */
12
10
  type Refinement<A, B extends A> = (value: A) => value is B;
11
+ /** Predicate that accepts an unknown value and narrows it to `T`. */
12
+ type Predicate<T> = Refinement<unknown, T>;
13
13
  /** Readability alias for {@link Predicate}. */
14
14
  type Guard<T> = Predicate<T>;
15
15
  /** Readability alias for {@link Refinement}. */
@@ -27,8 +27,8 @@ type ParseResult<T> = {
27
27
  } | {
28
28
  valid: false;
29
29
  };
30
- /** Extracts the narrowed output type from a predicate. */
31
- type GuardedOf<F> = F extends ((value: unknown) => value is infer G) ? G : never;
30
+ /** Extracts the narrowed output type from a predicate or refinement. */
31
+ type GuardedOf<F> = F extends Refinement<infer A, infer B> ? B : never;
32
32
  /** Extracts guard outputs that remain assignable to a known input type. */
33
33
  type GuardedWithin<Fs, A> = Extract<Fs extends readonly unknown[] ? GuardedOf<Fs[number]> : never, A>;
34
34
 
@@ -92,7 +92,8 @@ type OptionalObjectKeys<T> = {
92
92
  */
93
93
  type RequiredObjectKeys<T> = Exclude<keyof T, OptionalObjectKeys<T>>;
94
94
  /**
95
- * Schema shape checked against an existing object type by `typedStruct`.
95
+ * String-keyed schema shape checked against an existing object type by
96
+ * `typedStruct`. Numeric and symbol properties are excluded.
96
97
  */
97
98
  type TypedStructShape<T extends object> = {
98
99
  readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>;
@@ -204,14 +205,28 @@ declare function narrowKeyTo<A, K extends keyof A>(guard: Guard<A>, key: K): <co
204
205
  */
205
206
  declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
206
207
 
208
+ type RefinementInputs<In, Outputs extends readonly unknown[]> = readonly [
209
+ In,
210
+ ...Outputs
211
+ ];
212
+ /** Builds an ordered refinement tuple from its initial input and output tuple. */
213
+ type RefinementsFromOutputs<In, Outputs extends readonly unknown[]> = {
214
+ [K in keyof Outputs]: Refinement<RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>], Outputs[K] & RefinementInputs<In, Outputs>[K & keyof RefinementInputs<In, Outputs>]>;
215
+ };
216
+ /** Returns the last tuple member, or a fallback for an empty tuple. */
217
+ type LastOr<Default, T extends readonly unknown[]> = T extends readonly [
218
+ ...unknown[],
219
+ infer Tail
220
+ ] ? Tail : Default;
221
+
207
222
  /**
208
- * Combines a precondition guard with an additional refinement to narrow the type.
223
+ * Combines a precondition refinement with an additional refinement.
209
224
  * Prefer this over hand-written `precondition(x) && condition(x)` when the
210
- * composed predicate should be reused as a guard.
225
+ * composed refinement should be reused.
211
226
  *
212
227
  * @param precondition Broad guard evaluated first; short-circuits on failure.
213
228
  * @param condition Refinement evaluated only when `precondition` passes.
214
- * @returns Predicate that narrows the input to a subtype.
229
+ * @returns Refinement that preserves the precondition's input domain.
215
230
  * @example
216
231
  * const isPositiveNumber = and(
217
232
  * isNumber,
@@ -220,14 +235,16 @@ declare function lazy<T>(factory: () => Predicate<T>): Predicate<T>;
220
235
  * @see andAll
221
236
  */
222
237
  declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A, B>): Predicate<B>;
238
+ declare function and<A, B extends A, C extends B>(precondition: Refinement<A, B>, condition: Refine<NoInfer<B>, C>): Refinement<A, C>;
223
239
  /**
224
- * Chains a sequence of refinements after a precondition, returning the final guard type.
240
+ * Chains refinements while preserving the precondition's input domain.
225
241
  * Use this instead of nested `&&` checks when each step should keep narrowing
226
242
  * the next refinement.
243
+ * Pass a generic readonly chain as one tuple to preserve its final narrowing.
227
244
  *
228
245
  * @param precondition Initial guard applied first.
229
246
  * @param steps Subsequent refinements applied in order.
230
- * @returns Guard reflecting the result of the refinement chain.
247
+ * @returns Refinement reflecting the final result of the chain.
231
248
  * @example
232
249
  * const isPublicTitle = andAll(isString, minLength(4), startsWithPublic);
233
250
  * @see and
@@ -235,18 +252,27 @@ declare function and<A, B extends A>(precondition: Guard<A>, condition: Refine<A
235
252
  declare function andAll<A>(precondition: Guard<A>): Guard<A>;
236
253
  declare function andAll<A, B extends A>(precondition: Guard<A>, step1: Refine<A, B>): Guard<B>;
237
254
  declare function andAll<A, B extends A, C extends B>(precondition: Guard<A>, step1: Refine<A, B>, step2: Refine<B, C>): Guard<C>;
238
- /**
239
- * Logical OR over multiple guards.
240
- * Prefer this over hand-written `guardA(x) || guardB(x)` when the composed
241
- * predicate should be reused as a guard.
242
- *
243
- * @param guards Guards to evaluate; passes if any guard passes.
244
- * @returns Guard for the union of all guarded types.
255
+ declare function andAll<A, Chain extends readonly Refine<unknown, unknown>[]>(precondition: Guard<A>, ...steps: Chain & RefineChain<A, Chain>): Guard<ChainResult<A, Chain>>;
256
+ declare function andAll<A, B extends A>(precondition: Refinement<A, B>): Refinement<A, B>;
257
+ declare function andAll<A, B extends A, C extends B>(precondition: Refinement<A, B>, step1: Refine<NoInfer<B>, C>): Refinement<A, C>;
258
+ 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>;
259
+ 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>>;
260
+ 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>>;
261
+ 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>>;
262
+ declare function andAll<A, B extends A>(precondition: Refinement<A, B>, ...steps: readonly Refine<NoInfer<B>, NoInfer<B>>[]): Refinement<A, B>;
263
+ /**
264
+ * Logical OR over refinements sharing an input domain.
265
+ * Prefer this over hand-written `refineA(x) || refineB(x)` when the composed
266
+ * refinement should be reused.
267
+ *
268
+ * @param refinements Refinements to evaluate; passes if any refinement passes.
269
+ * @returns Refinement for the union of all narrowed types.
245
270
  * @example
246
271
  * const isId = or(isString, isNumber);
247
272
  * @see oneOf
248
273
  */
249
274
  declare function or<P extends readonly Guard<unknown>[]>(...guards: P): Guard<OutOfGuards<P>>;
275
+ 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]>>;
250
276
  /**
251
277
  * Adapts a guard so it can be used as a refinement within a known supertype.
252
278
  *
@@ -661,13 +687,14 @@ declare function nonEmptyArrayOf<F extends Predicate<unknown>>(elementGuard: F):
661
687
  declare function mapOf<KF extends Predicate<unknown>, VF extends Predicate<unknown>>(keyGuard: KF, valueGuard: VF): Predicate<ReadonlyMap<GuardedOf<KF>, GuardedOf<VF>>>;
662
688
 
663
689
  /**
664
- * Combines multiple guards; passes when any one guard matches.
690
+ * Combines refinements sharing an input domain.
665
691
  *
666
- * @param guards One or more type guards/refinements to try.
667
- * @returns Predicate that narrows to the union of guarded types.
692
+ * @param refinements One or more refinements to try.
693
+ * @returns Refinement that narrows to the union of matching types.
668
694
  */
669
695
  declare function oneOf<Fs extends readonly Predicate<unknown>[]>(...guards: Fs): Predicate<GuardedOf<Fs[number]>>;
670
696
  declare function oneOf<A, Fs extends readonly Predicate<A>[]>(...guards: Fs): (input: A) => input is GuardedWithin<Fs, A>;
697
+ 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]>>;
671
698
 
672
699
  /**
673
700
  * Creates a guard that matches when the input is one of the provided literal values.
@@ -721,7 +748,9 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
721
748
  declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
722
749
 
723
750
  /**
724
- * Creates a `struct` builder checked against an existing object type.
751
+ * Creates a `struct` builder checked against an existing string-keyed object
752
+ * type. Numeric and symbol properties are excluded from the checked shape and
753
+ * cannot be validated by the resulting guard.
725
754
  * Optional target keys must also be declared with `optionalKey` so type drift
726
755
  * stays visible when the target type changes.
727
756
  *
package/dist/index.js CHANGED
@@ -275,29 +275,19 @@ function lazy(factory) {
275
275
  };
276
276
  }
277
277
 
278
- // src/utils/to-boolean-predicates.ts
279
- var toBooleanPredicates = (predicates) => predicates;
280
-
281
278
  // src/core/logic.ts
282
279
  function and(precondition, condition) {
283
- return define((input) => {
284
- if (precondition(input)) {
285
- return condition(input);
286
- }
287
- return false;
288
- });
280
+ return (input) => !!(precondition(input) && condition(input));
289
281
  }
290
- function andAll(precondition, ...steps) {
291
- return define((input) => {
282
+ function andAll(precondition, stepOrSteps, ...remainingSteps) {
283
+ const steps = stepOrSteps === void 0 ? remainingSteps : isFunction(stepOrSteps) ? [stepOrSteps, ...remainingSteps] : [...stepOrSteps, ...remainingSteps];
284
+ return (input) => {
292
285
  if (!precondition(input)) return false;
293
- return applyRefinements(input, steps);
294
- });
286
+ return steps.every((step) => step(input));
287
+ };
295
288
  }
296
- function or(...guards) {
297
- const predicates = toBooleanPredicates(guards);
298
- return define(
299
- (input) => predicates.some((guard) => guard(input))
300
- );
289
+ function or(...refinements) {
290
+ return (input) => refinements.some((refinement) => refinement(input));
301
291
  }
302
292
  function guardIn() {
303
293
  return (guard) => (input) => guard(input);
@@ -305,13 +295,6 @@ function guardIn() {
305
295
  function not(fn) {
306
296
  return (input) => !fn(input);
307
297
  }
308
- function applyRefinements(value, steps) {
309
- if (!steps || steps.length === 0) return true;
310
- for (const step of steps) {
311
- if (!step(value)) return false;
312
- }
313
- return true;
314
- }
315
298
 
316
299
  // src/core/nullish.ts
317
300
  var allowWhen = (acceptedValue, predicate) => (value) => acceptedValue(value) || predicate(value);
@@ -455,8 +438,8 @@ function mapOf(keyGuard, valueGuard) {
455
438
  }
456
439
 
457
440
  // src/core/combinators/one-of.ts
458
- function oneOf(...guards) {
459
- return or(...guards);
441
+ function oneOf(...refinements) {
442
+ return (input) => refinements.some((refinement) => refinement(input));
460
443
  }
461
444
 
462
445
  // src/core/combinators/one-of-values.ts
@@ -572,6 +555,9 @@ function tupleOf(...guards) {
572
555
  (input) => Array.isArray(input) && everyTupleValue(input, guards)
573
556
  );
574
557
  }
558
+
559
+ // src/utils/to-boolean-predicates.ts
560
+ var toBooleanPredicates = (predicates) => predicates;
575
561
  // Annotate the CommonJS export names for ESM import in node:
576
562
  0 && (module.exports = {
577
563
  and,
package/dist/index.mjs CHANGED
@@ -170,29 +170,19 @@ function lazy(factory) {
170
170
  };
171
171
  }
172
172
 
173
- // src/utils/to-boolean-predicates.ts
174
- var toBooleanPredicates = (predicates) => predicates;
175
-
176
173
  // src/core/logic.ts
177
174
  function and(precondition, condition) {
178
- return define((input) => {
179
- if (precondition(input)) {
180
- return condition(input);
181
- }
182
- return false;
183
- });
175
+ return (input) => !!(precondition(input) && condition(input));
184
176
  }
185
- function andAll(precondition, ...steps) {
186
- return define((input) => {
177
+ function andAll(precondition, stepOrSteps, ...remainingSteps) {
178
+ const steps = stepOrSteps === void 0 ? remainingSteps : isFunction(stepOrSteps) ? [stepOrSteps, ...remainingSteps] : [...stepOrSteps, ...remainingSteps];
179
+ return (input) => {
187
180
  if (!precondition(input)) return false;
188
- return applyRefinements(input, steps);
189
- });
181
+ return steps.every((step) => step(input));
182
+ };
190
183
  }
191
- function or(...guards) {
192
- const predicates = toBooleanPredicates(guards);
193
- return define(
194
- (input) => predicates.some((guard) => guard(input))
195
- );
184
+ function or(...refinements) {
185
+ return (input) => refinements.some((refinement) => refinement(input));
196
186
  }
197
187
  function guardIn() {
198
188
  return (guard) => (input) => guard(input);
@@ -200,13 +190,6 @@ function guardIn() {
200
190
  function not(fn) {
201
191
  return (input) => !fn(input);
202
192
  }
203
- function applyRefinements(value, steps) {
204
- if (!steps || steps.length === 0) return true;
205
- for (const step of steps) {
206
- if (!step(value)) return false;
207
- }
208
- return true;
209
- }
210
193
 
211
194
  // src/core/nullish.ts
212
195
  var allowWhen = (acceptedValue, predicate) => (value) => acceptedValue(value) || predicate(value);
@@ -350,8 +333,8 @@ function mapOf(keyGuard, valueGuard) {
350
333
  }
351
334
 
352
335
  // src/core/combinators/one-of.ts
353
- function oneOf(...guards) {
354
- return or(...guards);
336
+ function oneOf(...refinements) {
337
+ return (input) => refinements.some((refinement) => refinement(input));
355
338
  }
356
339
 
357
340
  // src/core/combinators/one-of-values.ts
@@ -467,6 +450,9 @@ function tupleOf(...guards) {
467
450
  (input) => Array.isArray(input) && everyTupleValue(input, guards)
468
451
  );
469
452
  }
453
+
454
+ // src/utils/to-boolean-predicates.ts
455
+ var toBooleanPredicates = (predicates) => predicates;
470
456
  export {
471
457
  and,
472
458
  andAll,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-kit",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Zero-dependency TypeScript runtime validation toolkit for composable type guards and natural type narrowing.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -43,7 +43,7 @@
43
43
  "bugs": {
44
44
  "url": "https://github.com/nyaomaru/is-kit/issues"
45
45
  },
46
- "homepage": "https://is-kit-docs.vercel.app/",
46
+ "homepage": "https://is-kit.dev/",
47
47
  "author": "nyaomaru",
48
48
  "license": "MIT",
49
49
  "devDependencies": {
@@ -69,6 +69,7 @@
69
69
  "test": "jest",
70
70
  "test:types": "tsd",
71
71
  "test:package": "node tests/package-smoke.mjs",
72
+ "test:package:vlt": "node tests/vlt-package-smoke.mjs",
72
73
  "lint": "oxlint .",
73
74
  "format": "oxfmt .",
74
75
  "format:check": "oxfmt --check .",