Skip to content

Promise Helpers

Utility functions for working with promise operations.

FunctionDescription
consoleLogPromiseReturns a function that logs data to the console and passes it through.
deferRuns an async function and guarantees that all deferred callbacks are executed afterwards, in LIFO order (last regist…
delayCreates a promise that resolves after specified delay
falsyPromiseOrThrowReturns a function that passes through falsy data or throws an error.
guardWraps a function so that if it throws, a default value is returned instead of propagating the error.
meaningPromiseOrThrowReturns a function that passes through meaningful data or throws an error.
parallelRuns an array of async functions with a concurrency limit.
resolveRecordResolves an array of keys into a record by calling an async mapper for each key.
retryRetries a promise-returning function up to maxAttempts times
safeFetchWraps fetch with built-in error handling: returns null when the request fails (network error, non-OK status, or p…
timeoutWraps a promise to reject with a TimeoutError if it does not resolve within the specified duration.
truthyPromiseOrThrowReturns a function that passes through truthy data or throws an error.
tryitWraps a function so it never throws.
withResolversnative JS Promise.withResolvers() (ES2024)