easy-monad
    Preparing search index...

    Type Alias Maybe<T>

    Maybe: {
        doIfNoValue: (fn: () => void) => Maybe<T>;
        doIfNoValueAsync: (fn: () => Promise<void>) => MaybeAsync<T>;
        doIfValue: (fn: (x: T) => void) => Maybe<T>;
        doIfValueAsync: (fn: (x: T) => Promise<void>) => MaybeAsync<T>;
        getOrElse: <A>(x: A) => T | A;
        hasValue: boolean;
        mapValue: <A>(fn: (x: T) => A | Maybe<A>) => Maybe<A>;
        mapValueAsync: <A>(fn: (x: T) => Promise<A | Maybe<A>>) => MaybeAsync<A>;
    } & { [key: symbol]: true }

    Represent a value that may or may not be present

    Type Parameters

    • T

    Type declaration

    • doIfNoValue: (fn: () => void) => Maybe<T>

      Execute a function, only if a value is NOT present.

    • doIfNoValueAsync: (fn: () => Promise<void>) => MaybeAsync<T>

      Execute an asynchrone function, only if a value is NOT present.

    • doIfValue: (fn: (x: T) => void) => Maybe<T>

      Execute a function only if a value is present. Will not update the value. If you want to update the value use mapValue instead.

    • doIfValueAsync: (fn: (x: T) => Promise<void>) => MaybeAsync<T>

      Execute an asynchrone function, only if a value is present. Will not update the value. If you want to update the value use mapValueAsync instead.

    • getOrElse: <A>(x: A) => T | A

      Get the value if any. Else return a default value.

    • hasValue: boolean

      Whether Maybe has a value or not

    • mapValue: <A>(fn: (x: T) => A | Maybe<A>) => Maybe<A>

      Transform the value, if any. If the result of the maping is another Maybe, it will be flatten automatically

    • mapValueAsync: <A>(fn: (x: T) => Promise<A | Maybe<A>>) => MaybeAsync<A>

      transform the value, if any, with an asynchrone operation. If the result of the maping is another Maybe, it will be flatten automatically

    • [key: symbol]: true