/** Type used to represent either success or failure. */ export interface IResult { /** Returns the value if result is `Ok`, `undefined` if `Err`. */ ok(): T | undefined; /** Returns `true` if result is `Ok`, `false` if `Err`. */ isOk(): boolean; /** Returns the error if result is `Err`, `undefined` if `Ok`. */ err(): E | undefined; /** Returns `true` if result is `Err`, `false` if `Ok`. */ isErr(): boolean; /** * Maps an `IResult` to `IResult` by applying the function provided * to a contained `Ok` value, leaving an `Err` value untouched. */ map(op: (value: T) => U): IResult; /** * Maps an `IResult` to `IResult` by applying the function provided * to a contained `Err` value, leaving an `Ok` value untouched. */ mapErr(op: (error: E) => F): IResult; /** * Returns `res` if the receiver is `Ok`, otherwise returns the `Err` value of * the receiver. */ and(res: IResult): IResult; /** * Invokes `op` if the receiver is `Ok`, returning the result. * If the receiver is `Err`, returns the `Err` value of the receiver. */ andThen(op: (value: T) => IResult): IResult; /** * Unwraps the result, yielding the contents of the receiver if `Ok`. * Throws an exception if the receiver is an `Err`. */ unwrap(): T; /** * Unwraps the result, yielding the contents of the receiver if `Err`. * Throws an exception if the receiver is an `Ok`. */ unwrapErr(): E; /** * Unwraps a result, yielding the content if the receiver is `Ok`. * If the receiver is an `Err`, returns `outherwise`. */ unwrapOr(otherwise: T): T; /** * Unwraps a result, yielding the content if the receiver is `Ok`. * If the receiver is an `Err`, returns the result of invoking the parameter. */ unwrapOrElse(otherwise: (error: E) => T): T; } /** Contains the success value. */ export declare class Ok implements IResult { private value; constructor(v: T); ok(): T | undefined; isOk(): boolean; err(): E | undefined; isErr(): boolean; map(op: (value: T) => U): IResult; mapErr(op: (error: E) => F): IResult; and(res: IResult): IResult; andThen(op: (value: T) => IResult): IResult; unwrap(): T; unwrapErr(): E; unwrapOr(otherwise: T): T; unwrapOrElse(otherwise: (error: E) => T): T; } /** Contains the error value. */ export declare class Err implements IResult { private value; constructor(v: E); ok(): T | undefined; isOk(): boolean; err(): E | undefined; isErr(): boolean; map(op: (value: T) => U): IResult; mapErr(op: (error: E) => F): IResult; and(res: IResult): IResult; andThen(op: (value: T) => IResult): IResult; unwrap(): T; unwrapErr(): E; unwrapOr(otherwise: T): T; unwrapOrElse(otherwise: (error: E) => T): T; }