Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "promise/monadic-operations"

Index

Functions

lift

  • lift<T>(value: T, thisArg: Object): PromiseLike<T>
  • Lifts a single value or a function into a Promise-like object. Provides a method of wrapping a single value or a function into a Promise, in order that the following operation may conform to the standard Promise operation. In some scenario, we may first attempt to get a value from cache. Motivation. In this case, we need to return a value. However, if the value is not available in the cache, we may have to go ahead to load it asynchronously. Loading a value asynchronously usually returns a Promise. To untify the return from two cases, we escalate a single value into a Promise.

    Type parameters

    • T

    Parameters

    • value: T
    • thisArg: Object

    Returns PromiseLike<T>

liftIntoReject

  • liftIntoReject<T>(value: T): PromiseLike<T>

liftToPredicate

  • liftToPredicate<T>(promise: PromiseLike<T>, guard: function): PromiseLike<boolean>
  • Converts the given promise into a promise which does not reject anything.

    Type parameters

    • T

    Parameters

    • promise: PromiseLike<T>
    • guard: function
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns PromiseLike<boolean>

liftWithGuard

  • liftWithGuard<T>(promise: PromiseLike<T>, guard: function): PromiseLike<T>
  • Converts a given promise into another promise which ensures that the given guard evalutes to be true from the state of the given promise.

    Type parameters

    • T

    Parameters

    • promise: PromiseLike<T>
    • guard: function
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns PromiseLike<T>

readerPipeline

  • readerPipeline<T, U>(readerPromise: PromiseLike<T>, settings: IPipelineSettings<U>): PromiseLike<U>
  • Transforms a given promise with additonal pipeline processing. Specifically, in this method, compared to the given promise, the return promise contains validating and adpating stages.

    Type parameters

    • T

    • U

    Parameters

    Returns PromiseLike<U>

settle

  • settle<T>(promise: PromiseLike<T>): PromiseLike<T>

transform

  • transform<T>(promise: PromiseLike<T>): PromiseLike<T>
  • Transforms a given promise into one promise with our own implementation.

    Type parameters

    • T

    Parameters

    • promise: PromiseLike<T>

    Returns PromiseLike<T>

Generated using TypeDoc