Maybe

interface Maybe<T extends NonNullable<{}>> {
    [iterator](): Iterator<T, any, undefined>;
    ap<V extends {}>(maybeFn: monet.Maybe<((val: T) => V)>): monet.Maybe<V>;
    apTo<V extends {}>(value: monet.Maybe<V>): T extends ((arg: V) => any)
        ? monet.Maybe<ReturnType<T<T>>>
        : never;
    bind<V extends {}>(fn: ((val: T) => monet.Maybe<V>)): monet.Maybe<V>;
    cata<Z>(none: (() => Z), some: ((val: T) => Z)): Z;
    catchMap(fn: (() => monet.Maybe<T>)): monet.Maybe<T>;
    chain<V extends {}>(fn: ((val: T) => monet.Maybe<V>)): monet.Maybe<V>;
    contains(val: T): boolean;
    equals(other: monet.Maybe<T>): boolean;
    every(fn: ((e: T) => boolean)): boolean;
    exists(fn: ((e: T) => boolean)): boolean;
    fantasy-land/equals?(other: monet.Maybe<T>): boolean;
    filter<U extends {}>(fn: ((val: T) => val is U)): monet.Maybe<U>;
    filter(fn: ((val: T) => boolean)): monet.Maybe<T>;
    filterNot<U extends {}>(fn: ((val: T) => val is U)): monet.Maybe<Exclude<T, U>>;
    filterNot(fn: ((val: T) => boolean)): monet.Maybe<T>;
    flatMap<V extends {}>(fn: ((val: T) => monet.Maybe<V>)): monet.Maybe<V>;
    fold<V>(val: V): ((fn: ((val: T) => V)) => V);
    foldLeft<V>(initial: V): ((fn: ((acc: V, val: T) => V)) => V);
    foldRight<V>(initial: V): ((fn: ((val: T, acc: V) => V)) => V);
    forEach(fn: ((val: T) => void)): void;
    forall(fn: ((e: T) => boolean)): boolean;
    getOrElse(val: T): T;
    isJust(): boolean;
    isNone(): boolean;
    isNothing(): boolean;
    isSome(): boolean;
    join<V>(): T extends monet.Maybe<V>
        ? V
        : never;
    just(): T;
    map<V extends {}>(fn: ((val: T) => V)): monet.Maybe<V>;
    orElse(maybe: monet.Maybe<T>): monet.Maybe<T>;
    orElseRun(fn: (() => void)): void;
    orJust(val: T): T;
    orLazy(fn: (() => undefined | null | T)): T;
    orNoneIf(val: boolean): monet.Maybe<T>;
    orNothingIf(val: boolean): monet.Maybe<T>;
    orNull(): null | T;
    orSome(val: T): T;
    orUndefined(): undefined | T;
    some(): T;
    takeLeft(m: monet.Maybe<T>): monet.Maybe<T>;
    takeRight(m: monet.Maybe<T>): monet.Maybe<T>;
    to<I extends Iterable<T>>(ctor: ((iter: Iterable<T>) => I)): I;
    toArray(): T[];
    toEither<E>(left?: E): monet.Either<E, T>;
    toList(): monet.List<T>;
    toSet(): Set<T>;
    toValidation<E>(fail?: E): monet.Validation<E, T>;
}

Type Parameters

Hierarchy-Diagram

UML class diagram of Maybe
Legend
icon for an interface in the UML class diagram interface
icon for a public method in the UML class diagram public method

Hierarchy (view full)

Methods

  • Type Parameters

    • Z

    Parameters

    • none: (() => Z)
        • (): Z
        • Returns Z

    • some: ((val: T) => Z)
        • (val: T): Z
        • Parameters

          • val: T

          Returns Z

    Returns Z

  • Parameters

    • val: T

    Returns boolean

  • Parameters

    • fn: ((e: T) => boolean)
        • (e: T): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Parameters

    • fn: ((e: T) => boolean)
        • (e: T): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Type Parameters

    • U extends {}

    Parameters

    • fn: ((val: T) => val is U)
        • (val: T): val is U
        • Parameters

          • val: T

          Returns val is U

    Returns monet.Maybe<U>

  • Parameters

    • fn: ((val: T) => boolean)
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns monet.Maybe<T>

  • Type Parameters

    • U extends {}

    Parameters

    • fn: ((val: T) => val is U)
        • (val: T): val is U
        • Parameters

          • val: T

          Returns val is U

    Returns monet.Maybe<Exclude<T, U>>

  • Parameters

    • fn: ((val: T) => boolean)
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns monet.Maybe<T>

  • Type Parameters

    • V

    Parameters

    • val: V

    Returns ((fn: ((val: T) => V)) => V)

      • (fn: ((val: T) => V)): V
      • Parameters

        • fn: ((val: T) => V)
            • (val: T): V
            • Parameters

              • val: T

              Returns V

        Returns V

  • Type Parameters

    • V

    Parameters

    • initial: V

    Returns ((fn: ((acc: V, val: T) => V)) => V)

      • (fn: ((acc: V, val: T) => V)): V
      • Parameters

        • fn: ((acc: V, val: T) => V)
            • (acc: V, val: T): V
            • Parameters

              • acc: V
              • val: T

              Returns V

        Returns V

  • Type Parameters

    • V

    Parameters

    • initial: V

    Returns ((fn: ((val: T, acc: V) => V)) => V)

      • (fn: ((val: T, acc: V) => V)): V
      • Parameters

        • fn: ((val: T, acc: V) => V)
            • (val: T, acc: V): V
            • Parameters

              • val: T
              • acc: V

              Returns V

        Returns V

  • Parameters

    • fn: ((val: T) => void)
        • (val: T): void
        • Parameters

          • val: T

          Returns void

    Returns void

  • Parameters

    • fn: ((e: T) => boolean)
        • (e: T): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Parameters

    • val: T

    Returns T

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Type Parameters

    • V

    Returns T extends monet.Maybe<V>
        ? V
        : never

  • Returns T

  • Type Parameters

    • V extends {}

    Parameters

    • fn: ((val: T) => V)
        • (val: T): V
        • Parameters

          • val: T

          Returns V

    Returns monet.Maybe<V>

  • Parameters

    • fn: (() => void)
        • (): void
        • Returns void

    Returns void

  • Parameters

    • val: T

    Returns T

  • Parameters

    • fn: (() => undefined | null | T)
        • (): undefined | null | T
        • Returns undefined | null | T

    Returns T

  • Parameters

    • val: boolean

    Returns monet.Maybe<T>

  • Parameters

    • val: boolean

    Returns monet.Maybe<T>

  • Returns null | T

  • Parameters

    • val: T

    Returns T

  • Returns undefined | T

  • Returns T

  • Returns T[]

  • Type Parameters

    • E

    Parameters

    • Optional left: E

    Returns monet.Either<E, T>

  • Returns Set<T>