Merge pull request #32960 from ethanbishop/feature/p-retry-3

p-retry: Update to 3.0.
This commit is contained in:
Mine Starks
2019-02-12 11:48:24 -08:00
committed by GitHub
2 changed files with 3 additions and 4 deletions
+2 -2
View File
@@ -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 {
+1 -2
View File
@@ -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;