import { ErrFrom, OkFrom, Option, OptionPromise, Result, ResultLike, ResultMapOption, ResultMapOrElse, ResultMapResult, ResultPromise, ResultPromiseLike, ResultPromiseMapOption, ResultPromiseMapOrElse, ResultPromiseMapResult, UnwrapableResult } from "./mod"; /** * Test that a variable implements the {@linkcode Option} interface * @returns true if variable can be cast to `Option` */ export declare function isResult(possibleResult: unknown): possibleResult is Result; export declare function isResultPromise(possibleResult: unknown): possibleResult is ResultPromise; export declare function isResultLike(possibleResult: unknown): possibleResult is ResultLike; /** * Creates a `Result` with an `Ok` value of type T. * * When the value is {@linkcode ResultLike}, the actual return value is that. * When the value is a Promise to T, the return value implements {@linkcode ResultPromise} */ export declare function Ok(ok: T): OkFrom; /** * Create an {@linkcode ResultPromise} from a value. * @example * ```typescript * declare function calculate(n: number): ResultPromise; * * Ok(42) * .mapResult( * // when using Ok here, the compiler will error on calculate with an Argument Error * () => OkPromise(-1), * calculate * ); * ``` */ export declare function OkPromise(value: T): ResultPromise; /** * Creates a `Result` with an `Err` value of type E. * * When the value is {@linkcode ResultLike}, the actual return value is that. * When the value is a Promise to E, the return value implements {@linkcode ResultPromise} */ export declare function Err(err: E): ErrFrom; /** * Create an {@linkcode ResultPromise} from a value. * @example * ```typescript * declare function calculate(n: number): ResultPromise; * * Ok(42) * .mapResult( * // when using Err here, the compiler will error on calculate with an Argument Error * () => ErrPromise("could not calculate"), * calculate * ); * ``` */ export declare function ErrPromise(err: E): ResultPromise; export declare class ResultValue implements Result, UnwrapableResult { result: UnwrapableResult; constructor(result: UnwrapableResult); get type(): symbol; static from(result: UnwrapableResult): Result; and(res: Result): Result; andThen(op: (value: T) => ResultPromiseLike): ResultPromise; andThen(op: (value: T) => Result): Result; err(): Option; isOk(): boolean; isErr(): boolean; map(fn: (value: T) => Promise): PromisedResult; map(fn: (value: T) => U): Result; mapErr(fn: (err: E) => Promise): ResultPromise; mapErr(fn: (err: E) => F): Result; mapResult(def: (err: E) => U, fn: (value: T) => U): ResultMapResult; mapOption(def: (err: E) => U, fn: (value: T) => U): ResultMapOption; mapOrElse(def: (err: E) => U, fn: (value: T) => U): ResultMapOrElse; ok(): Option; or(optb: Result): Result; orElse(fn: (err: E) => Promise>): PromisedResult; orElse(fn: (err: E) => Result): Result; unwrap(): T; unwrapOr(def: T): T; unwrapOrElse(def: (err: E) => T): T; unwrapOrElse(def: (err: E) => Promise): T | Promise; [Symbol.iterator](): IterableIterator; } type Creator = ((v: T) => OkFrom) | ((e: E) => OkFrom); export declare class PromisedResult implements ResultPromise { private promise; constructor(promise: Promise>, creator: Creator); get [Symbol.toStringTag](): string; static from(promise: Promise>, then?: Creator): ResultPromise; then, TResult2 = never>(onfulfilled?: ((value: Result) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | undefined | null): Promise; catch(onrejected?: ((reason: unknown) => TResult | PromiseLike) | null | undefined): Promise | TResult>; finally(onfinally?: (() => void) | null | undefined): Promise>; and(res: Result): ResultPromise; andThen(fn: (value: T) => ResultLike): ResultPromise; err(): OptionPromise; isOk(): Promise; isErr(): Promise; map(fn: (value: T) => Promise): ResultPromise; map(fn: (value: T) => U): ResultPromise; mapErr(fn: (err: E) => Promise): ResultPromise; mapErr(fn: (err: E) => F): ResultPromise; mapResult(def: (err: E) => U, fn: (value: T) => U): ResultPromiseMapResult; mapOption(def: (err: E) => U, fn: (value: T) => U): ResultPromiseMapOption; mapOrElse(def: (err: E) => U, fn: (value: T) => U): ResultPromiseMapOrElse; ok(): OptionPromise; or(optb: Result): ResultPromise; orElse(fn: (err: E) => Promise>): ResultPromise; orElse(fn: (err: E) => Result): ResultPromise; unwrapOr(def: T): Promise; unwrapOrElse(def: (err: E) => T): Promise; unwrapOrElse(def: (err: E) => Promise): Promise; } export {};