UNPKG

castage

Version:

A type-safe library for dynamic object casting and ensuring type consistency in JavaScript/TypeScript.

7 lines (6 loc) 727 B
import { Result } from 'resultage'; import { CastingError, CastingErrorCode, CasterFn, Caster, ParserFn } from './types.js'; export declare const casterApi: <T>(casterFn: CasterFn<T>, name?: string, parser?: ParserFn<T>) => Caster<T>; export declare const fromGuard: <T>(guard: (value: any) => value is T, name?: string, errorCode?: CastingErrorCode) => Caster<T>; export declare const fromGuardAndTransform: <T, S>(guard: (value: any) => value is T, transform: (value: T, path: string[]) => Result<S, CastingError>, name?: string, errorCode?: CastingErrorCode, parser?: (value: T, path: string[]) => Result<S, CastingError[]>) => Caster<S>; export declare const is: <T>(caster: CasterFn<T>) => (value: unknown) => value is T;