/** * @template T, E */ export class Result { /** * @template T * @param {T} value */ static ok(value: T_1): Ok; /** * @template E * @param {E} error */ static err(error: E_1): Err; static chain(fn: any, self: any): any; static map(fn: any, self: any): any; static alt(other: any, self: any): any; static equals(other: any, self: any): any; static lte(other: any, self: any): any; /** * @returns {this is Ok} */ isOk(): this is Ok; /** * @returns {this is Err} */ isErr(): this is Err; } /** @template T, E */ export class Ok extends Result { /** @param {T} value */ constructor(value: T); /** * @returns {this is Ok} */ isOk(): this is Ok; /** * @returns {this is Err} */ isErr(): this is Err; /** * @template {Result} R * @param {(value: T) => R} fn * @returns {R} */ andThen>(fn: (value: T) => R): R; /** * @template V * @template {Result} R * @param {(value: T) => V} fn * @returns {R} */ map>(fn: (value: T) => V): R; /** * @template V * @param {V} _defaultValue * @param {(value: T) => V} fn * @returns {V} */ mapOr(_defaultValue: V, fn: (value: T) => V): V; /** * @param {Result} other * @returns {Result} */ and(other: Result): Result; /** * @param {Result} _other * @returns {Result} */ or(_other: Result): Result; /** * @template F * @param {(error: E) => Result} _fn * @returns {Result} */ orElse(_fn: (error: E) => Result): Result; /** * @param {Result} other * @returns {boolean} */ equals(other: Result): boolean; /** * @param {Result} other * @returns {boolean} */ lte(other: Result): boolean; /** * @template [V=T] * @param {(acc: V, value: T) => V} reducer * @param {V} init * @returns {V} */ reduce(reducer: (acc: V, value: T) => V, init: V): V; /** * @template {Result} R * @returns {R} */ flatten>(): R; /** * @returns {Option} */ ok(): Option; /** * @returns {Option} */ err(): Option; /** * @param {(value: T) => void} fn * @returns {this} */ inspect(fn: (value: T) => void): this; /** * @returns {T} * @throws {UnwrapError} */ unwrap(): T; /** * @returns {E} * @throws {UnwrapError} */ unwrapErr(): E; /** * @param {T} _value * @returns {T} */ unwrapOr(_value: T): T; /** * @param {() => T} _fn * @returns {T} */ unwrapOrElse(_fn: () => T): T; #private; } /** @template T, E */ export class Err extends Result { /** @param {E} error */ constructor(error: E); /** * @returns {this is Ok} */ isOk(): this is Ok; /** * @returns {this is Err} */ isErr(): this is Err; /** * @template {Result} R * @param {(value: T) => R} _fn * @returns {R} */ andThen>(_fn: (value: T) => R): R; /** * @template V * @template {Result} R * @param {(value: T) => V} _fn * @returns {R} */ map>(_fn: (value: T) => V): R; /** * @template V * @param {V} defaultValue * @param {(value: T) => V} _fn * @returns {V} */ mapOr(defaultValue: V, _fn: (value: T) => V): V; /** * @template V * @param {() => V} defaultFn * @param {(value: T) => V} _fn * @returns {V} */ mapOrElse(defaultFn: () => V, _fn: (value: T) => V): V; /** * @template T * @param {Result} _other * @returns {Result} */ and(_other: Result): Result; /** * @template T * @param {Result} other * @returns {Result} */ or(other: Result): Result; /** * @template T, F * @param {(error: E) => Result} fn * @returns {Result} */ orElse(fn: (error: E) => Result): Result; /** * @template T * @param {Result} other * @returns {boolean} */ equals(other: Result): boolean; /** * @template T * @param {Result} other * @returns {boolean} */ lte(other: Result): boolean; /** * @template [V=T] * @param {(acc: V, value: T) => V} _reducer * @param {V} init * @returns {V} */ reduce(_reducer: (acc: V, value: T) => V, init: V): V; /** * @template {Result} R * @returns {R} */ flatten>(): R; /** * @returns {Option} */ ok(): Option; /** * @returns {Option} */ err(): Option; /** * @template T * @param {(value: T) => void} _fn * @returns {this} */ inspect(_fn: (value: T_1) => void): this; /** * @template T * @returns {T} * @throws {UnwrapError} */ unwrap(): T_1; /** * @returns {E} * @throws {UnwrapError} */ unwrapErr(): E; /** * @param {T} value * @returns {T} */ unwrapOr(value: T): T; /** * @template T * @param {() => T} fn * @returns {T} */ unwrapOrElse(fn: () => T_1): T_1; #private; } import { Option } from './option.js'; //# sourceMappingURL=result.d.ts.map