UNPKG

alwz

Version:

Extendable library for typecasting

35 lines 998 B
import { Type } from '../constants/types.js'; export type Guard<T> = (input?: unknown) => input is T; declare const _default: { /** * @example * const isString = type('string'); * isString(1); // false * isString('1'); // true */ type: <Name extends keyof import("../constants/types.js").TypesMap>(type: Name) => Guard<Type<Name>>; /** * @example * class Test {} * const isTest = instance(Test); * isTest({}); // false * isTest(new Test()); // true */ instance: <T>(prototype: T) => Guard<T>; /** * @example * const isVariant = variant([1, 2, 3]); * isVariant(4); // false * isVariant(3); // true */ variant: <T_1>(list: T_1[]) => Guard<T_1>; /** * @example * const isOdd = check((v) => v % 2 ? true : false); * isOdd(0); // false * isOdd(1); // true */ check: <T_2>(guard: Guard<T_2>) => Guard<T_2>; }; export default _default; //# sourceMappingURL=Is.d.ts.map