#async Clear
Tags #utils #browser #performance #array #async #dom #objects #pattern #events #format #concurrency #http #ui #advanced #fetch #url #string #functional #cache #files #crypto #promise #intl #observer
JavaScript Fetch with Retry
Wraps the native fetch API with automatic retry logic using exponential backoff. Retries on network errors or non-OK HTTP responses up to a configurable number of attempts. Exponential backoff with optional jitter prevents thundering herd problems when many clients retry simultaneously.
JavaScript Async Sleep / Delay
Returns a Promise that resolves after a given number of milliseconds. Use with await to pause async functions without blocking the main thread. More readable than nested setTimeout callbacks and composable with other async utilities.
JavaScript Promise All with Concurrency Limit
Runs an array of async tasks with a maximum concurrency cap, preventing you from firing hundreds of requests simultaneously. Processes items in batches, moving to the next as slots free up. Essential when hitting rate-limited APIs or processing large datasets without overwhelming the server.
JavaScript Retry Promise with Backoff
Retries a Promise-returning function up to a specified number of times with configurable exponential backoff and optional jitter. Accepts a shouldRetry predicate so you can skip retries on specific error types (e.g. 401 Unauthorized). Returns the resolved value or re-throws the last error after exhausting retries.
JavaScript Queue (Async Task Queue)
A serialised async task queue that executes queued async functions one at a time, in order. Useful for sequencing operations that must not run concurrently (file writes, ordered API mutations, step-by-step wizards). add() returns a Promise that resolves/rejects when that specific task completes.
JavaScript Long Polling Helper
Implements a long-polling loop that repeatedly calls a fetch endpoint and invokes a callback with the result. Backs off exponentially on errors and stops cleanly when cancelled via the returned stop function. A simple alternative to WebSockets for low-frequency server-push events without SSE support.