Type-safe utilities and combinators for building isXXX guards in TypeScript. Lightweight and zero-dependency.
Installation
pnpm add is-kit
Usage
import { define } from 'is-kit';const isString = define<string>((x) => typeof x === 'string');if (isString('hello')) {// narrowed to string}
Features
Type-safe predicates
Author and compose predicates that refine types precisely.
API Reference
define
Wrap a predicate as a typed guard.
struct
Shape guard for objects; supports exact key checking.
logic
Logical combinators: and, andAll, or, not, guardIn.
parse
Safe parsing with tagged results.
primitive
Primitive guards: string, number, boolean, etc.
predicate
Convert boolean predicates to refinements.