predicatory
v2.1.1
Published
Zero dependency type-safe user defined type guard factory.
Downloads
2
Readme
predicatory
Zero dependency type-safe user defined type guard factory.
Install
$ npm i predicatory
or
$ yarn add predicatory
How to use
import { guard } from 'predicatory'
// this inferred `(value: unknown) => value is string`
export const isString = guard((value, never) =>
typeof value === 'string' ? value : never,
)
// this inferred `(value: any) => value is number`
export const isNumber = guard(Number)
License
MIT