mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
Merge pull request #32960 from ethanbishop/feature/p-retry-3
p-retry: Update to 3.0.
This commit is contained in:
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for p-retry 2.0
|
||||
// Type definitions for p-retry 3.0
|
||||
// Project: https://github.com/sindresorhus/p-retry#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -19,7 +19,7 @@ declare namespace pRetry {
|
||||
|
||||
interface FailedAttemptError extends Error {
|
||||
attemptNumber: number;
|
||||
attemptsLeft: number;
|
||||
retriesLeft: number;
|
||||
}
|
||||
|
||||
interface Options extends OperationOptions {
|
||||
|
||||
@@ -7,14 +7,13 @@ const run = () => fetch('https://sindresorhus.com/unicorn')
|
||||
if (response.status === 404) {
|
||||
throw new pRetry.AbortError(response.statusText);
|
||||
}
|
||||
|
||||
return response.text();
|
||||
});
|
||||
|
||||
pRetry(run, {
|
||||
retries: 5,
|
||||
onFailedAttempt: error => {
|
||||
console.log(`Attempt ${error.attemptNumber} failed. There are ${error.attemptsLeft} attempts left.`);
|
||||
console.log(`Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} attempts left.`);
|
||||
}
|
||||
}).then(result => {
|
||||
const str: string = result;
|
||||
|
||||
Reference in New Issue
Block a user