UNPKG

shapeit

Version:

Object validation tools for Javascript and, specially, Typescript

21 lines (20 loc) 496 B
import { Guard } from '../types/guards'; /** * Creates a guard from a typeguard function * * @example * const myCustomType = sp.guard('myCustomType', (input): input is MyCustomType => { * let result : boolean; * * // test if input is MyCustomType * * return result; * }); */ export default function guard<T>(name: string, validator: (input: unknown) => input is T): Guard<T>; /** * This is an alias for sp.guard * * @alias guard */ export declare const custom: typeof guard;