UNPKG

return-style

Version:

Non-intrusively convert the result of any function or promise to the user's desired style.

25 lines (24 loc) 810 B
import { Option } from './option.js'; export declare class Result<T, E> { private type; private value?; private error?; private constructor(); private constructor(); static Ok<T, E>(value: T): Result<T, E>; static Err<T, E>(error: E): Result<T, E>; isOk(): boolean; isErr(): boolean; map<U>(mapper: (val: T) => U): Result<U, E>; mapErr<U>(mapper: (err: E) => U): Result<T, U>; mapOr<U>(defaultValue: U, mapper: (val: T) => U): U; mapOrElse<U>(createDefaultValue: (err: E) => U, mapper: (val: T) => U): U; unwrap(): T; unwrapOr<U>(defaultValue: U): T | U; unwrapOrElse<U>(createDefaultValue: (err: E) => U): T | U; unwrapErr(): E; expect(message: string): T; expectErr(message: string): E; ok(): Option<T>; err(): Option<E>; }