export interface RetryOptions { /** Retries after the first try. Defaults to 3. */ attempts?: number; /** Wait before the first retry, in ms. Defaults to 1000. */ delay?: number; /** Multiplier applied to the wait after each retry. Defaults to 2. */ backoff?: number; /** Upper bound on any single wait, in ms. Defaults to none. */ maxDelay?: number; /** Shortens each wait by a random share of up to this fraction (`true` is 1), so callers failing together do not retry together. Defaults to none. */ jitter?: boolean | number; /** Returning false stops retrying and rethrows `error` as is. Defaults to retrying every error. */ shouldRetry?: (error: unknown, attempt: number) => boolean; /** Fires before each wait. */ onRetry?: (error: unknown, attempt: number, nextDelay: number) => void; /** Stops before the next try or during a wait, rejecting with the signal's reason. */ signal?: AbortSignal | undefined; } export declare function retry(fn: (retryCount: number) => Promise, { attempts, delay, backoff, maxDelay, jitter, shouldRetry, onRetry, signal }?: RetryOptions): Promise; export declare class TimeoutError extends Error { } export interface TimeoutOptions { /** Defaults to 5000. */ ms?: number; /** The `TimeoutError` message, to tell which operation ran out. */ message?: string; /** Aborts the wait and the signal handed to `fn`. */ signal?: AbortSignal; } /** Runs `fn` within a deadline. `fn` gets a signal aborted on expiry, so the work itself can stop instead of running on unseen. */ export declare function timeout(fn: (signal: AbortSignal) => Promise, msOrOptions?: number | TimeoutOptions): Promise; export interface MapConcurrentOptions { /** Calls in flight at once. Defaults to all of them. */ limit?: number; /** Stops handing out items and rejects with the signal's reason; calls in flight are not cancelled. */ signal?: AbortSignal; /** Resolve with every call's `PromiseSettledResult` instead of rejecting on the first failure. */ settle?: boolean; } /** * Maps over `items` with at most `limit` calls in flight, keeping the results in input order. * * Unlike a chunked `Promise.all`, a worker takes the next item as soon as it is free, so one slow item does not hold up the rest of its batch. */ export declare function mapConcurrent(items: T[], limit: number, fn: (item: T, index: number) => Promise): Promise; export declare function mapConcurrent(items: T[], options: MapConcurrentOptions & { settle: true; }, fn: (item: T, index: number) => Promise): Promise[]>; export declare function mapConcurrent(items: T[], options: MapConcurrentOptions & { settle?: false; }, fn: (item: T, index: number) => Promise): Promise; export declare function mapConcurrent(items: T[], options: MapConcurrentOptions, fn: (item: T, index: number) => Promise): Promise[]>; /** The work's answer if it lands inside `ms`, else `fallback`. Only the wait is bounded: the work keeps running and its answer is dropped, which is what makes this the right shape for a budget (a render, a page's seeds) rather than for cancelling the work itself. */ export declare function within(work: Promise, ms: number, fallback?: F): Promise; //# sourceMappingURL=promise.d.ts.map