axios-retryer
Version:
axios-retryer is an advanced Axios request manager offering intelligent retry logic with token refresh, concurrency control, priority queuing, and a flexible plugin architecture, all built with TypeScript for robust HTTP client integrations.
19 lines (17 loc) • 820 B
TypeScript
import type { AxiosRetryerBackoffType } from '../types';
/**
* Returns a delay (in milliseconds) given an attempt number and a backoff strategy.
*
* @param attempt - The number of the current retry attempt (1-based)
* @param backoffType - 'static', 'linear', or 'exponential'
* - 'static': returns a fixed 1000ms delay
* - 'linear': grows linearly with attempt (1000 * attempt)
* - 'exponential': doubles with each attempt (1000 * 2^(attempt - 1))
* @returns The calculated delay in milliseconds.
*
* @example
* getBackoffDelay(1, 'static') -> 1000
* getBackoffDelay(3, 'linear') -> 3000
* getBackoffDelay(4, 'exponential') -> 8000 ± up to 500 ms
*/
export declare function getBackoffDelay(attempt: number, backoffType: AxiosRetryerBackoffType): number;