Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > Async

Async class

Utilities for parallel asynchronous operations, for use with the system Promise APIs.

Signature:

export declare class Async 

Methods

Method

Modifiers

Description

forEachAsync(iterable, callback, options)

static

Given an input array and a callback function, invoke the callback to start a promise for each element in the array.

forEachAsync(iterable, callback, options)

static

Given an input array and a callback function, invoke the callback to start a promise for each element in the array.

getSignal()

static

Returns a Signal, a.k.a. a "deferred promise".

mapAsync(iterable, callback, options)

static

Given an input array and a callback function, invoke the callback to start a promise for each element in the array. Returns an array containing the results.

mapAsync(iterable, callback, options)

static

Given an input array and a callback function, invoke the callback to start a promise for each element in the array. Returns an array containing the results.

runWithRetriesAsync({ action, maxRetries, retryDelayMs }, input)

static

Executes an async function and optionally retries it if it fails.

runWithTimeoutAsync({ action, timeoutMs, timeoutMessage }, input)

static

Runs a promise with a timeout. If the promise does not resolve within the specified timeout, it will reject with an error.

sleepAsync(ms)

static

Return a promise that resolves after the specified number of milliseconds.

validateWeightedIterable(operation)

static

Ensures that the argument is a valid IWeighted, with a weight argument that is a positive integer or 0.