Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PromiseConstructor

Hierarchy

  • PromiseConstructor

Index

Constructors

constructor

  • new PromiseConstructor<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>
  • Creates a new Promise.

    Type parameters

    • T

    Parameters

    • executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void

      A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.

        • (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void): void
        • Parameters

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

                • value: T | PromiseLike<T>

                Returns void

          • reject: (reason?: any) => void
              • (reason?: any): void
              • Parameters

                • Optional reason: any

                Returns void

          Returns void

    Returns Promise<T>

Properties

Readonly [Symbol.species]

[Symbol.species]: PromiseConstructor

Readonly prototype

prototype: Promise<any>

A reference to the prototype.

Methods

all

  • all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>
  • all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>
  • all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>
  • all<T1, T2, T3, T4, T5, T6, T7, T8>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>
  • all<T1, T2, T3, T4, T5, T6, T7>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5, T6, T7]>
  • all<T1, T2, T3, T4, T5, T6>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5, T6]>
  • all<T1, T2, T3, T4, T5>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4, T5]>
  • all<T1, T2, T3, T4>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3, T4]>
  • all<T1, T2, T3>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2, T3]>
  • all<T1, T2>(values: readonly (T1 | PromiseLike<T1>)[]): Promise<[T1, T2]>
  • all<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>
  • 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<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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    • T10

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>

    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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>

    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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>

    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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7]>

    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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5, T6]>

    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

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4, T5]>

    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

    • T1

    • T2

    • T3

    • T4

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3, T4]>

    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

    • T1

    • T2

    • T3

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2, T3]>

    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

    • T1

    • T2

    Parameters

    • values: readonly (T1 | PromiseLike<T1>)[]

      An array of Promises.

    Returns Promise<[T1, T2]>

    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

    Parameters

    • values: readonly (T | PromiseLike<T>)[]

      An array of Promises.

    Returns Promise<T[]>

    A new Promise.

allSettled

  • allSettled<T>(values: T): Promise<{-readonly [ P in string | number | symbol]-?: PromiseSettledResult<T[P] extends PromiseLike<U> ? U : T[P]> }>
  • allSettled<T>(values: Iterable<T>): Promise<PromiseSettledResult<T extends PromiseLike<U> ? U : T>[]>
  • allSettled(promises: Promise<any>[]): Promise<{ reason?: any; status: "fulfilled" | "rejected"; value?: any }[]>
  • 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[] | readonly unknown[]

    Parameters

    • values: T

      An array of Promises.

    Returns Promise<{-readonly [ P in string | number | symbol]-?: PromiseSettledResult<T[P] extends PromiseLike<U> ? U : 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>

      An array of Promises.

    Returns Promise<PromiseSettledResult<T extends PromiseLike<U> ? U : T>[]>

    A new Promise.

  • Parameters

    • promises: Promise<any>[]

    Returns Promise<{ reason?: any; status: "fulfilled" | "rejected"; value?: any }[]>

any

  • any<T>(values: (T | PromiseLike<T>)[] | Iterable<T | PromiseLike<T>>): Promise<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

    Parameters

    • values: (T | PromiseLike<T>)[] | Iterable<T | PromiseLike<T>>

      An array or iterable of Promises.

    Returns Promise<T>

    A new Promise.

race

  • race<T>(values: Iterable<T>): Promise<T extends PromiseLike<U> ? U : T>
  • race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>
  • race<T>(values: readonly T[]): Promise<T extends PromiseLike<U> ? U : T>
  • 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>

      An iterable of Promises.

    Returns Promise<T extends PromiseLike<U> ? U : 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

    Parameters

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

      An iterable of Promises.

    Returns Promise<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

    Parameters

    • values: readonly T[]

      An array of Promises.

    Returns Promise<T extends PromiseLike<U> ? U : T>

    A new Promise.

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.

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