import { Collection } from './collection.js'; import { Either } from './either.js'; import { ArrayIterable } from './array-iterable.js'; import { HashSet } from './hashset.js'; import { HashMap } from './hashmap.js'; import { Mappable } from './mappable.js'; export interface OptionMatch { some: (value: A) => T; none: () => T; } export declare abstract class Option extends ArrayIterable> implements Mappable { abstract readonly get: A; static when(cond: boolean): (a: () => A) => Option; static useless(cond: boolean): (a: () => A) => Option; protected fromArray(array: A[]): Option; exists(p: (value: A) => boolean): boolean; filter(p: (value: A) => boolean): Option; filterNot(p: (value: A) => boolean): Option; map(f: (item: A) => B): Option; flatMap(p: (value: A) => Option): Option; mapPromise(f: (v: A) => Promise): Promise>; flatMapPromise(f: (item: A) => Promise>): Promise>; foldValue(ifEmpty: () => B): (f: (_: A) => B) => B; forall(p: (_: A) => boolean): boolean; foreach(f: (_: A) => void): void; getOrElse(f: () => A): A; getOrElseValue(other: A): A; getOrElseThrow(error: () => Error): A; contains(x: A1): boolean; get isDefined(): boolean; orElse(alternative: () => Option): Option; orElseValue(alternative: Option): Option; get orNull(): A | null; get orUndefined(): A | undefined; get toCollection(): Collection; toRight(left: () => X): Either; toLeft(right: () => X): Either; get toArray(): A[]; get toSet(): HashSet; match(matcher: OptionMatch): T; toMap(mapper: (item: A) => [K, V]): HashMap; } export declare class Some extends Option { private readonly value; constructor(value: A); get get(): A; get isEmpty(): boolean; } export declare class None extends Option { get get(): A; get isEmpty(): boolean; } export declare function option(value: A | null | undefined): Option; export declare function some(value: A): Some; export declare const none: Option;