Type-veilige hulpprogramma’s om isXXX-guards te bouwen in TypeScript. Lichtgewicht, geen dependencies.
Installatie
pnpm add is-kit
Gebruik
import { define } from 'is-kit';const isString = define<string>((x) => typeof x === 'string');if (isString('hello')) {// narrowed to string}
Functies
Type-veilige predicaten
Stel predicaten samen die types precies verfijnen.
API Referentie
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.