Function retry

Retries an async function with exponential backoff. Useful for handling transient failures in network requests, etc.

const fetchWithRetry = retry({ maxAttempts: 3 })(fetchData);
const data = await fetchWithRetry();
  • Parameters

    Returns <T>(fn: () => Promise<T>) => () => Promise<T>

    Wrapped function that retries on failure