Class SyncPromise<T>

A promise that will make its resolved or rejected values synchronously available and operable.

Type Parameters

  • T

Hierarchy (view full)

Constructors

Accessors

Methods

  • Attaches a callback for only the rejection of the Promise.

    Type Parameters

    • TF = never

    Parameters

    • Optionalonrejected: null | Callable<unknown, TF | PromiseLike<TF>>

      The callback to execute when the Promise is rejected.

    Returns Promise<T | TF>

    A Promise for the completion of the callback.

  • Returns a Promise if pending, otherwise it will synchronously return or throw.

    Returns T | Promise<T>

  • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

    Parameters

    • Optionalonfinally: null | Callable

      The callback to execute when the Promise is settled (fulfilled or rejected).

    Returns Promise<T>

    A Promise for the completion of the callback.

  • An agnostic and chainable method to operate on a SyncPromise. It will execute asynchronously if values are pending, and synchronously otherwise.

    Type Parameters

    • TS = T
    • TF = never

    Parameters

    • Optionalsuccess: null | Callable<T, TS | PromiseLike<TS>>
    • Optionalfailure: null | Callable<unknown, TF | PromiseLike<TF>>
    • Optionalfinalize: null | Callable<void, void | PromiseLike<void>>

    Returns SyncPromise<TS | TF>

  • Attaches callbacks for the resolution and/or rejection of the Promise.

    Type Parameters

    • TS = T
    • TF = never

    Parameters

    • Optionalonfulfilled: null | Callable<T, TS | PromiseLike<TS>>

      The callback to execute when the Promise is resolved.

    • Optionalonrejected: null | Callable<unknown, TF | PromiseLike<TF>>

      The callback to execute when the Promise is rejected.

    Returns Promise<TS | TF>

    A Promise for the completion of which ever callback is executed.