Type Parameters

  • T

Hierarchy

Properties

then: (<TResult1, TResult2>(onfulfilled?, onrejected?) => PromiseLike<TResult1 | TResult2>)

Type declaration

    • <TResult1, TResult2>(onfulfilled?, onrejected?): PromiseLike<TResult1 | TResult2>
    • WARNING: This is implemented only for Promise compatibility. Please use chain instead.

      Type Parameters

      Parameters

      • Optional onfulfilled: null | ((value) => TResult1 | PromiseLike<TResult1>)
      • Optional onrejected: null | ((reason) => TResult2 | PromiseLike<TResult2>)

      Returns PromiseLike<TResult1 | TResult2>

Methods

  • Returns the first Just between the future value of this and another future Maybe or future Nothing if both this and the argument are Nothing

    Parameters

    Returns functional.MaybeAsync<T>

  • Maps the future value of this with another future Maybe function

    Type Parameters

    • U

    Parameters

    Returns functional.MaybeAsync<Awaited<U>>

  • Structural pattern matching for MaybeAsync in the form of a function

    Type Parameters

    • U

    Parameters

    Returns Promise<U>

  • Returns this if it resolves to Nothing, otherwise it returns the result of applying the function argument to the value of this and wrapping it in a Just

    Type Parameters

    • U

    Parameters

    Returns functional.MaybeAsync<Awaited<U>>

  • Type Parameters

    • U

    Parameters

    • pred: ((value) => value is U)
        • (value): value is U
        • Parameters

          • value: T

          Returns value is U

    Returns functional.MaybeAsync<U>

  • Parameters

    • pred: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns functional.MaybeAsync<T>

  • Takes a predicate function and returns this if the predicate, applied to the resolved value, is true or Nothing if it's false

    Type Parameters

    • U

    Parameters

    • pred: ((value) => value is U)
        • (value): value is U
        • Parameters

          • value: T

          Returns value is U

    Returns functional.MaybeAsync<U>

  • Takes a predicate function and returns this if the predicate, applied to the resolved value, is true or Nothing if it's false

    Parameters

    • pred: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns functional.MaybeAsync<T>

  • Runs an effect if this is Just, returns this to make chaining other methods possible

    Parameters

    • effect: ((value) => any)
        • (value): any
        • Parameters

          • value: T

          Returns any

    Returns functional.MaybeAsync<T>

  • Runs an effect if this is Nothing, returns this to make chaining other methods possible

    Parameters

    • effect: (() => any)
        • (): any
        • Returns any

    Returns functional.MaybeAsync<T>

  • Transforms the value inside this with a given function. If the MaybeAsync that is being mapped resolves to Nothing then the mapping function won't be called and run will resolve the whole thing to Nothing, just like the regular Maybe#map

    Type Parameters

    • U

    Parameters

    • f: ((value) => U)
        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns functional.MaybeAsync<Awaited<U>>

  • Returns the default value if this is Nothing, otherwise it returns a Promise that will resolve to the value inside this

    Parameters

    • defaultValue: T

    Returns Promise<T>

  • It's important to remember how run will behave because in an async context there are other ways for a function to fail other than to return a Nothing, for example: If any of the computations inside MaybeAsync resolved to Nothing, run will return a Promise resolved to Nothing. If any of the promises were to be rejected then run will return a Promise resolved to Nothing. If an exception is thrown then run will return a Promise resolved to Nothing. If none of the above happen then a promise resolved to the returned value wrapped in a Just will be returned.

    Returns Promise<functional.Maybe<T>>

  • Converts this to a EitherAsync with a default error value

    Type Parameters

    • L

    Parameters

    • error: L

    Returns functional.EitherAsync<L, T>

Generated using TypeDoc