-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add optional delay for retry
#335
Conversation
experimental.d.ts
Outdated
@@ -23,7 +23,7 @@ export const echo: Echo | |||
interface Retry { | |||
(pieces: TemplateStringsArray, ...args: any[]): Promise<ProcessOutput> | |||
} | |||
export const retry: (count: number) => Retry | |||
export const retry: <C extends number = 5, D extends number = 0>(count?: C, delay?: D) => Retry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why extend 5?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const retry: (count: number = 5) => Retry
raises TS2371: A parameter initializer is only allowed in a function or constructor implementation
.
So the only way to add a default arg value to fn type declaration is via generics (afair).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, reverted
@@ -23,7 +23,7 @@ export const echo: Echo | |||
interface Retry { | |||
(pieces: TemplateStringsArray, ...args: any[]): Promise<ProcessOutput> | |||
} | |||
export const retry: (count: number) => Retry | |||
export const retry: (count?: number, delay?: number) => Retry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better. Fixes an issue.
Some cmds (like
npm whoami
) may hit the throttling limit, so adelay
between call attempt might be very useful.