UNPKG

berrserk

Version:

Lightweight TypeScript library for type-safe errors-as-values

14 lines (13 loc) 491 B
type Either<TResult, TError = Error> = Success<TResult> | Failure<TError>; type Success<TResult> = { data: TResult; error?: undefined; }; type Failure<TError = Error> = { data?: undefined; error: TError; }; export declare function withError(callback: () => never): Failure; export declare function withError<TResult>(callback: () => Promise<TResult>): Promise<Either<TResult>>; export declare function withError<TResult>(callback: () => TResult): Either<TResult>; export {};