import { MapOption, Option, OptionFrom, OptionLike, OptionMapOption, OptionMapOrElse, OptionMapResult, OptionPromise, OptionPromiseMapOption, OptionPromiseMapOrElse, OptionPromiseMapResult, Result, ResultPromise, UnwrapableOption } from "./mod"; /** * Create an {@linkcode OptionPromise} from a value. * @example * ```typescript * declare function calculate(n: number): OptionPromise; * Some(42) * .mapOption( * // when using Some here, the compiler will error on calculate with an Argument Error * () => SomePromise(-1), * calculate * ); * ``` */ export declare function SomePromise(value: T): OptionPromise; /** * `None` creates an Option that has no associated value. It might be useful to * pass a type argument: * ```typescript * const token = None(); * token.insert(12); // will give a compile error that the argument must be string * ``` */ export declare function None(): Option; /** * Create an {@linkcode OptionPromise} without a value. * @example * ```typescript * declare function calculate(n: number): OptionPromise; * Some(42) * .mapOption( * // when using Some here, the compiler will error on calculate with an Argument Error * () => NonePromise, * calculate * ); * ``` */ export declare function NonePromise(): OptionPromise; /** * `Some` creates an Option which has an associated value. The type argument can be * inferred from the argument. Actually, `Some` is a bit special, as it also might * return a `None` value: * ```typescript * // All the statements below return a None * Some(); * Some(null); * Some(Infinity); * Some(NaN); * ``` * Passing a promise to `Some` results in an {@linkcode OptionPromise}, which can be * convenient. When a `OptionPromise` is required e.g., for {@linkcode mapOrElse}, * {@linkcode NonePromise} or {@linkcode SomePromise} */ export declare function Some(value?: T | undefined | null): OptionFrom; /** * Test that a variable implements the {@linkcode Option} interface * @returns true if variable can be cast to `Option` * * @example * ```typescript * const vut: unknown = Some(42); * if (isOption(vut)) { * console.log(vut.unwrapOr(-99)); * } * ``` */ export declare function isOption(possibleOption: unknown): possibleOption is Option; /** * Test that a variable implements the {@linkcode OptionPromise} interface * @returns true if variable can be cast to `OptionPromise` * * @example * const vut: unknown = Some(Promise.resolve(42)); * if (isOptionPromise(vut)) { * vut.map(console.log); * } */ export declare function isOptionPromise(possibleOption: unknown): possibleOption is OptionPromise; export declare function isOptionLike(possibleOption: unknown): possibleOption is OptionLike; export declare class OptionValue implements Option, UnwrapableOption { private option; constructor(option: UnwrapableOption); get type(): symbol; static from(option: UnwrapableOption): Option; and(optb: Option): Option; andThen(fn: (some: T) => Promise>): OptionPromise; andThen(fn: (some: T) => Option): Option; filter(predicate: (some: T) => boolean): Option; flatten(this: Option): Option; flatten(this: Option>): Option; getOrInsert(value: T): T; getOrInsertWith(fn: () => T): T; insert(value: T): T; isSome(): boolean; isNone(): boolean; map(fn: (some: T) => U): MapOption; mapOption(def: () => U, fn: (some: T) => U): OptionMapOption; mapResult(def: () => U, fn: (some: T) => U): OptionMapResult; mapOrElse(def: () => U, fn: (some: T) => U): OptionMapOrElse; okOr(err: E): Result; okOrElse(fn: () => Promise): ResultPromise; okOrElse(fn: () => E): Result; or(optb: Option): Option; orElse(fn: () => Promise>): OptionPromise; orElse(fn: () => Option): Option; replace(value: T): Option; take(): Option; unwrap(): T; unwrapOr(def: T): T; unwrapOrElse(def: () => T): T; unwrapOrElse(def: () => Promise): T | Promise; xor(optb: Option): Option; [Symbol.iterator](): IterableIterator; } export declare class PromisedOption implements OptionPromise { promise: Promise>; constructor(promise: Promise>); get [Symbol.toStringTag](): string; static from(promise: Promise>): OptionPromise; then, TResult2 = never>(onfulfilled?: ((value: Option) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; catch(onrejected?: ((reason: unknown) => TResult | PromiseLike) | null | undefined): Promise | TResult>; finally(onfinally?: (() => void) | null | undefined): Promise>; and(optb: Option): OptionPromise; andThen(fn: (some: T) => OptionPromise): OptionPromise; andThen(fn: (some: T) => Promise>): OptionPromise; andThen(fn: (some: T) => Option): OptionPromise; filter(predicate: (some: T) => boolean): OptionPromise; flatten(this: Option>): OptionPromise; flatten(this: Option): OptionPromise; isSome(): Promise; isNone(): Promise; map(fn: (some: T) => U): OptionPromise; mapOption(def: () => U, fn: (some: T) => U): OptionPromiseMapOption; mapResult(def: () => U, fn: (some: T) => U): OptionPromiseMapResult; mapOrElse(def: () => U, fn: (some: T) => U): OptionPromiseMapOrElse; okOr(err: E): ResultPromise; okOrElse(fn: () => Promise): ResultPromise; or(optb: Option): OptionPromise; orElse(fn: () => Promise>): OptionPromise; orElse(fn: () => Option): OptionPromise; unwrapOr(def: T): Promise; unwrapOrElse(def: () => T): Promise; unwrapOrElse(def: () => Promise): Promise; xor(optb: Option): OptionPromise; }