Skip to content

async

Contains utility functions for asynchronous operations.

Interface Description
InvokeAsyncSafelyAfterDelayParams Parameters for invokeAsyncSafelyAfterDelay.
RetryOptions Options for retryWithTimeout.
RetryWithTimeoutParams Options for retryWithTimeout.
RunWithTimeoutParams Options for runWithTimeout.
SleepParams Parameters for sleep.
TimeoutContext Context provided to the timeout handler.
TimeoutParams Parameters for timeout.
Function Description
addErrorHandler Adds an error handler to a Promise that catches any errors and emits an async error event.
asyncFilter Filters an array asynchronously, keeping only the elements that satisfy the provided predicate function.
asyncFilterInPlace Filters an array asynchronously in place, keeping only the elements that satisfy the provided predicate function.
asyncFlatMap Maps over an array asynchronously, applying the provided callback function to each element, and then flattens the results into a single array.
asyncMap Maps over an array asynchronously, applying the provided callback function to each element.
chain Chains a promise with another promise.
convertAsyncToSync Converts an asynchronous function to a synchronous one by automatically handling the Promise rejection.
convertSyncToAsync Converts a synchronous function to an asynchronous one by wrapping it in a Promise.
handleSilentError Handles a silent error.
ignoreError Ignores an error that is thrown by an asynchronous function.
invokeAsyncSafely Invokes a Promise and safely handles any errors by catching them and emitting an async error event.
invokeAsyncSafelyAfterDelay Invokes an asynchronous function after a delay.
isTerminationOnTimeoutEnabled Gets whether a runWithTimeout call without its own onTimeout terminates the operation when it times out.
marksAsTerminateRetry Marks an error to terminate retry logic.
neverEnds An async function that never ends.
nextTickAsync Gets the next tick.
normalizePromisable Converts to native promisable, converting PromiseLike (aka Thenable) to a native Promise.
promiseAllAsyncFnsSequentially Executes async functions sequentially.
promiseAllSequentially Executes promises sequentially.
queueMicrotaskAsync Gets the next queue microtask.
requestAnimationFrameAsync Gets the next request animation frame.
retryWithTimeout Retries the provided function until it returns true or the timeout is reached.
runWithTimeout Executes a function with a timeout. If the function does not complete within the specified time, it is considered to have timed out. Without an onTimeout, a timed-out function is terminated, unless the getTerminateOnTimeoutDebugSwitch debug switch is off, in which case it is allowed to run indefinitely.
setImmediateAsync Gets the next set immediate.
setTerminationOnTimeoutEnabled Sets whether a runWithTimeout call without its own onTimeout terminates the operation when it times out.
setTimeoutAsync Delays execution for a specified number of milliseconds.
sleep Delays execution for a specified number of milliseconds.
timeout Returns a Promise that rejects after the specified timeout period.
toArray Converts an AsyncIterableIterator to an array by consuming all its elements.
Type Description
PromiseResolve A type representing a function that resolves a Promise.