(fn: () => Promise<T>, options: RetryOptions = {})
| 172 | } |
| 173 | |
| 174 | export async function withRetry<T>(fn: () => Promise<T>, options: RetryOptions = {}): Promise<T> { |
| 175 | return retryWithPolicy(() => fn(), { |
| 176 | maxAttempts: options.attempts, |
| 177 | baseDelayMs: options.baseDelayMs, |
| 178 | maxDelayMs: options.maxDelayMs, |
| 179 | jitter: options.jitter, |
| 180 | shouldRetry: options.shouldRetry, |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | function computeDelay(base: number, max: number, jitter: number, attempt: number): number { |
| 185 | const exp = Math.min(max, base * 2 ** (attempt - 1)); |
no test coverage detected