Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbortablePromise<T>

Type parameters

  • T

Hierarchy

  • Promise<T>
    • AbortablePromise

Index

Constructors

constructor

  • new AbortablePromise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, signal: AbortSignal) => void, abortController?: AbortController): AbortablePromise<T>
  • Type parameters

    • T

    Parameters

    • executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, signal: AbortSignal) => void
        • (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, signal: AbortSignal): 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

          • signal: AbortSignal

          Returns void

    • abortController: AbortController = ...

    Returns AbortablePromise<T>

Properties

Readonly [Symbol.toStringTag]

[Symbol.toStringTag]: string

abortController

abortController: AbortController

Static Readonly [Symbol.species]

[Symbol.species]: PromiseConstructor

Methods

abort

catch

  • catch<TResult>(onRejected?: null | ((reason: any) => TResult | PromiseLike<TResult>)): AbortablePromise<T | TResult>

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>)): AbortablePromise<TResult1 | TResult2>
  • Type parameters

    • TResult1 = T

    • TResult2 = never

    Parameters

    • Optional onFulfilled: null | ((value: T) => TResult1 | PromiseLike<TResult1>)
    • Optional onRejected: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)

    Returns AbortablePromise<TResult1 | TResult2>

Static all

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

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    • T10

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]

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

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]

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

  • Type parameters

    • T1

    • T2

    • T3

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]

    Returns AbortablePromise<[T1, T2, T3]>

  • Type parameters

    • T1

    • T2

    Parameters

    • values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]

    Returns AbortablePromise<[T1, T2]>

Static 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>[]>
  • 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.

Static 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.

Static race

  • race<T>(values: readonly T[]): AbortablePromise<T extends PromiseLike<U> ? U : T>

Static reject

  • reject<T>(reason?: any): Promise<T>

Static resolve