Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Callbacks<T>

Type parameters

  • T = void

Hierarchy

  • Promise<T>
    • Callbacks

Index

Constructors

constructor

  • new Callbacks<T>(cb: undefined | null | ((value: void) => void | PromiseLike<void>)): Callbacks<T>
  • Type parameters

    • T = void

    Parameters

    • cb: undefined | null | ((value: void) => void | PromiseLike<void>)

    Returns Callbacks<T>

Properties

Optional reject

reject?: (value: T | PromiseLike<T>) => void

Type declaration

    • (value: T | PromiseLike<T>): void
    • Parameters

      • value: T | PromiseLike<T>

      Returns void

Optional resolve

resolve?: (value: T | PromiseLike<T>) => void

Type declaration

    • (value: T | PromiseLike<T>): void
    • Parameters

      • value: T | PromiseLike<T>

      Returns void

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns string

Static [species]

  • get [species](): PromiseConstructor
  • Returns PromiseConstructor

Methods

catch

  • catch<TResult>(onrejected?: null | ((reason: any) => TResult | PromiseLike<TResult>)): Promise<T | TResult>
  • Attaches a callback for only the rejection of the Promise.

    Type parameters

    • TResult = never

    Parameters

    • Optional onrejected: null | ((reason: any) => TResult | PromiseLike<TResult>)

      The callback to execute when the Promise is rejected.

    Returns Promise<T | TResult>

    A Promise for the completion of the callback.

finally

  • finally(onfinally?: null | (() => void)): 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

    • Optional onfinally: null | (() => void)

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

    Returns Promise<T>

    A Promise for the completion of the callback.

then

  • then<TResult1, TResult2>(onfulfilled?: null | ((value: T) => TResult1 | PromiseLike<TResult1>), onrejected?: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)): Promise<TResult1 | TResult2>
  • Attaches callbacks for the resolution and/or rejection of the Promise.

    Type parameters

    • TResult1 = T

    • TResult2 = never

    Parameters

    • Optional onfulfilled: null | ((value: T) => TResult1 | PromiseLike<TResult1>)

      The callback to execute when the Promise is resolved.

    • Optional onrejected: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)

      The callback to execute when the Promise is rejected.

    Returns Promise<TResult1 | TResult2>

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

Static all

  • all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>
  • all<T>(values: T): Promise<{ -readonly [ P in string | number | symbol]: Awaited<T[P]> }>
  • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

    Type parameters

    • T

    Parameters

    • values: Iterable<T | PromiseLike<T>>

      An iterable of Promises.

    Returns Promise<Awaited<T>[]>

    A new Promise.

  • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

    Type parameters

    • T: readonly unknown[] | []

    Parameters

    • values: T

      An array of Promises.

    Returns Promise<{ -readonly [ P in string | number | symbol]: Awaited<T[P]> }>

    A new Promise.

Static allSettled

  • allSettled<T>(values: T): Promise<{ -readonly [ P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>
  • allSettled<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]>
  • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

    Type parameters

    • T: readonly unknown[] | []

    Parameters

    • values: T

      An array of Promises.

    Returns Promise<{ -readonly [ P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>

    A new Promise.

  • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

    Type parameters

    • T

    Parameters

    • values: Iterable<T | PromiseLike<T>>

      An array of Promises.

    Returns Promise<PromiseSettledResult<Awaited<T>>[]>

    A new Promise.

Static any

  • any<T>(values: T): Promise<Awaited<T[number]>>
  • any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>
  • The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

    Type parameters

    • T: readonly unknown[] | []

    Parameters

    • values: T

      An array or iterable of Promises.

    Returns Promise<Awaited<T[number]>>

    A new Promise.

  • The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

    Type parameters

    • T

    Parameters

    • values: Iterable<T | PromiseLike<T>>

      An array or iterable of Promises.

    Returns Promise<Awaited<T>>

    A new Promise.

Static race

  • race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>
  • race<T>(values: T): Promise<Awaited<T[number]>>
  • Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

    Type parameters

    • T

    Parameters

    • values: Iterable<T | PromiseLike<T>>

      An iterable of Promises.

    Returns Promise<Awaited<T>>

    A new Promise.

  • Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

    Type parameters

    • T: readonly unknown[] | []

    Parameters

    • values: T

      An array of Promises.

    Returns Promise<Awaited<T[number]>>

    A new Promise.

Static reject

  • reject<T>(reason?: any): Promise<T>
  • Creates a new rejected promise for the provided reason.

    Type parameters

    • T = never

    Parameters

    • Optional reason: any

      The reason the promise was rejected.

    Returns Promise<T>

    A new rejected Promise.

Static resolve

  • resolve(): Promise<void>
  • resolve<T>(value: T | PromiseLike<T>): Promise<T>
  • Creates a new resolved promise.

    Returns Promise<void>

    A resolved promise.

  • Creates a new resolved promise for the provided value.

    Type parameters

    • T

    Parameters

    • value: T | PromiseLike<T>

      A promise.

    Returns Promise<T>

    A promise whose internal state matches the provided promise.

Generated using TypeDoc