Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SyncPromise<T>

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

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

Accessors

[toStringTag]

  • get [toStringTag](): string

Methods

catch

  • catch<TF>(onrejected?: null | UnaryFn<unknown, TF | PromiseLike<TF>>): Promise<T | TF>

consume

  • consume(): T | Promise<T>
  • Returns a Promise if pending, otherwise it will synchronously return or throw.

    Returns T | Promise<T>

finally

  • finally(onfinally?: null | NullaryFn<void>): Promise<T>

operate

  • operate<TS, TF>(success?: null | UnaryFn<T, TS | PromiseLike<TS>>, failure?: null | UnaryFn<unknown, TF | PromiseLike<TF>>, finalize?: null | NullaryFn<void | PromiseLike<void>>): SyncPromise<TS | TF>
  • 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

    • Optional success: null | UnaryFn<T, TS | PromiseLike<TS>>
    • Optional failure: null | UnaryFn<unknown, TF | PromiseLike<TF>>
    • Optional finalize: null | NullaryFn<void | PromiseLike<void>>

    Returns SyncPromise<TS | TF>

then

  • then<TS, TF>(onfulfilled?: null | UnaryFn<T, TS | PromiseLike<TS>>, onrejected?: null | UnaryFn<unknown, TF | PromiseLike<TF>>): Promise<TS | TF>
  • Type parameters

    • TS = T

    • TF = never

    Parameters

    • Optional onfulfilled: null | UnaryFn<T, TS | PromiseLike<TS>>
    • Optional onrejected: null | UnaryFn<unknown, TF | PromiseLike<TF>>

    Returns Promise<TS | TF>

Static from

  • from<T>(create: NullaryFn<T | PromiseLike<T>>): SyncPromise<T>

Generated using TypeDoc