@bodil/core - v0.4.7
    Preparing search index...

    Class AbortablePromise<A, E>

    A promise that can be aborted using an AbortSignal.

    Type Parameters

    • A

      The type of the resolved value of this promise.

    • E = Error

      The type of the rejected value of this promise. Defaults to Error, and it's usually best to keep it that way.

    Hierarchy

    Implements

    Index

    Properties

    "[toStringTag]": string
    "[species]": PromiseConstructor

    Accessors

    Methods

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

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

      Returns AbortablePromise<A, E>

      A Promise for the completion of the callback.

    • 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

      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 extends [] | readonly unknown[]

      Parameters

      • values: T

        An array of Promises.

      Returns Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P<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 extends [] | readonly unknown[]

      Parameters

      • values: T

        An array of Promises.

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

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

      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 extends [] | 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

      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

      Parameters

      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 extends [] | readonly unknown[]

      Parameters

      • values: T

        An array of Promises.

      Returns Promise<Awaited<T[number]>>

      A new Promise.

    • Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result in a Promise.

      Type Parameters

      • T
      • U extends unknown[]

      Parameters

      • callbackFn: (...args: U) => T | PromiseLike<T>

        A function that is called synchronously. It can do anything: either return a value, throw an error, or return a promise.

      • ...args: U

        Additional arguments, that will be passed to the callback.

      Returns Promise<Awaited<T>>

      A Promise that is:

      • Already fulfilled, if the callback synchronously returns a value.
      • Already rejected, if the callback synchronously throws an error.
      • Asynchronously fulfilled or rejected, if the callback returns a promise.
    • Creates a new Promise and returns it in an object, along with its resolve and reject functions.

      Type Parameters

      • T

      Returns PromiseWithResolvers<T>

      An object with the properties promise, resolve, and reject.

      const { promise, resolve, reject } = Promise.withResolvers<T>();