set retry config defaults without supplying empty object
This commit is contained in:
parent
463b0db759
commit
17225757d9
1 changed files with 2 additions and 2 deletions
|
|
@ -3,10 +3,10 @@
|
|||
*/
|
||||
export function withRetry<T extends unknown[], U>(
|
||||
fn: (...args: T) => Promise<U>,
|
||||
{ attempts = 6, backoffMs = (attempt) => 1000 * 2 ** attempt }: {
|
||||
{ attempts, backoffMs }: {
|
||||
attempts: number;
|
||||
backoffMs(attempt: number): number;
|
||||
},
|
||||
} = { attempts: 6, backoffMs: (attempt) => 1000 * 2 ** attempt },
|
||||
): (...args: T) => Promise<U> {
|
||||
return async (...args: T) => {
|
||||
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue