import { Option } from './option.js'; import { Collection } from './collection.js'; import { TryLike } from './try.js'; import { Mappable } from './mappable.js'; export interface EitherMatch { right: (right: RIGHT) => T; left: (left: LEFT) => T; } export declare abstract class Either implements Mappable { abstract match(matcher: EitherMatch): T; abstract get isLeft(): boolean; get isRight(): boolean; get left(): Either.LeftProjection; fold(fa: (left: LEFT) => C, fb: (right: RIGHT) => C): C; get swap(): Either; foreach(f: (right: RIGHT) => void): void; getOrElse(or: () => RIGHT): RIGHT; getOrElseValue(or: RIGHT): RIGHT; get orNull(): RIGHT | null; get orUndefined(): RIGHT | undefined; orElse(or: () => Either): Either; orElseValue(or: Either): Either; contains(elem: RIGHT): boolean; forall(f: (right: RIGHT) => boolean): boolean; exists(p: (right: RIGHT) => boolean): boolean; join[]>(...others: OTHERS): Either]>; flatMap(f: (value: RIGHT) => Either): Either; flatMapPromise(f: (item: RIGHT) => Promise>): Promise>; map(f: (value: RIGHT) => RIGHT1): Either; mapPromise(f: (v: RIGHT) => Promise): Promise>; filterOrElse(p: (v: RIGHT) => boolean, zero: () => LEFT): Either; filterOrElseValue(p: (v: RIGHT) => boolean, zero: LEFT): Either; get toCollection(): Collection; get toOption(): Option; toTry(toError?: (e: LEFT) => Error): TryLike; } export declare class Left extends Either { private readonly error; constructor(error: T); match(matcher: EitherMatch): X; get isLeft(): boolean; withRight(): Either; } export declare class Right extends Either { private readonly value; constructor(value: T); match(matcher: EitherMatch): X; get isLeft(): boolean; withLeft(): Either; } export declare namespace Either { type RightValue = E extends Either ? RIGHT : never; type RightValues[]> = { [K in keyof ES]: RightValue; }; function join, ...Either[]]>(...eithers: ES): Either>; class LeftProjection { private readonly e; constructor(e: Either); mapPromise(f: (item: A) => Promise): Promise>; flatMapPromise(f: (item: A) => Promise>): Promise>; foreach(f: (value: A) => U): void; getOrElse(or: () => A): A; getOrElseValue(or: A): A; forall(p: (value: A) => boolean): boolean; exists(p: (value: A) => boolean): boolean; flatMap(f: (value: A) => Either): Either; map(f: (value: A) => A1): Either; filterToOption(p: (value: A) => boolean): Option>; get toCollection(): Collection; get toOption(): Option; } } export declare function right(value: T): Right; export declare function left(value: E): Left;