@types/async-retry
Advanced tools
Comparing version 1.4.4 to 1.4.5
// Type definitions for async-retry 1.4 | ||
// Project: https://github.com/zeit/async-retry#readme | ||
// Project: https://github.com/vercel/async-retry | ||
// Definitions by: Albert Wu <https://github.com/albertywu> | ||
// Pablo Rodríguez <https://github.com/MeLlamoPablo> | ||
// Rafał Sawicki <https://github.com/rafsawicki> | ||
// BendingBender <https://github.com/BendingBender> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 | ||
import { WrapOptions } from 'retry'; | ||
declare function AsyncRetry<A>( | ||
fn: AsyncRetry.RetryFunction<A>, | ||
opts?: AsyncRetry.Options | ||
): Promise<A>; | ||
/** | ||
* Retrying made simple, easy, and async. | ||
* | ||
* @example | ||
* import retry = require('async-retry'); | ||
* import fetch from 'node-fetch'; | ||
* | ||
* await retry( | ||
* async (bail) => { | ||
* // if anything throws, we retry | ||
* const res = await fetch('https://google.com'); | ||
* | ||
* if (403 === res.status) { | ||
* // don't retry upon 403 | ||
* bail(new Error('Unauthorized')); | ||
* return; | ||
* } | ||
* | ||
* const data = await res.text(); | ||
* return data.substr(0, 500); | ||
* }, | ||
* { | ||
* retries: 5, | ||
* } | ||
* ); | ||
*/ | ||
declare function AsyncRetry<TRet>(fn: AsyncRetry.RetryFunction<TRet>, opts?: AsyncRetry.Options): Promise<TRet>; | ||
declare namespace AsyncRetry { | ||
interface Options extends WrapOptions { | ||
/** | ||
* An optional function that is invoked after a new retry is performed. It's passed the | ||
* `Error` that triggered it as a parameter. | ||
*/ | ||
onRetry?: ((e: Error, attempt: number) => any) | undefined; | ||
} | ||
type RetryFunction<A> = (bail: (e: Error) => void, attempt: number) => A|Promise<A>; | ||
/** | ||
* @param bail A function you can invoke to abort the retrying (bail). | ||
* @param attempt The attempt number. The absolute first attempt (before any retries) is `1`. | ||
*/ | ||
type RetryFunction<TRet> = (bail: (e: Error) => void, attempt: number) => TRet | Promise<TRet>; | ||
} | ||
export = AsyncRetry; |
{ | ||
"name": "@types/async-retry", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "TypeScript definitions for async-retry", | ||
@@ -22,2 +22,7 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/async-retry", | ||
"githubUsername": "rafsawicki" | ||
}, | ||
{ | ||
"name": "BendingBender", | ||
"url": "https://github.com/BendingBender", | ||
"githubUsername": "BendingBender" | ||
} | ||
@@ -36,4 +41,4 @@ ], | ||
}, | ||
"typesPublisherContentHash": "917ec0bd3b8bf2fac38200dd0124cd65513ce0c9e4ec6fbf0725204accd68ca8", | ||
"typeScriptVersion": "3.9" | ||
"typesPublisherContentHash": "6162feefbfc56fd9dcbe4b952d129bfcc941ef2b9db832c671fa9f9b3006f40e", | ||
"typeScriptVersion": "4.0" | ||
} |
@@ -5,3 +5,3 @@ # Installation | ||
# Summary | ||
This package contains type definitions for async-retry (https://github.com/zeit/async-retry#readme). | ||
This package contains type definitions for async-retry (https://github.com/vercel/async-retry). | ||
@@ -13,22 +13,53 @@ # Details | ||
// Type definitions for async-retry 1.4 | ||
// Project: https://github.com/zeit/async-retry#readme | ||
// Project: https://github.com/vercel/async-retry | ||
// Definitions by: Albert Wu <https://github.com/albertywu> | ||
// Pablo Rodríguez <https://github.com/MeLlamoPablo> | ||
// Rafał Sawicki <https://github.com/rafsawicki> | ||
// BendingBender <https://github.com/BendingBender> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 | ||
import { WrapOptions } from 'retry'; | ||
declare function AsyncRetry<A>( | ||
fn: AsyncRetry.RetryFunction<A>, | ||
opts?: AsyncRetry.Options | ||
): Promise<A>; | ||
/** | ||
* Retrying made simple, easy, and async. | ||
* | ||
* @example | ||
* import retry = require('async-retry'); | ||
* import fetch from 'node-fetch'; | ||
* | ||
* await retry( | ||
* async (bail) => { | ||
* // if anything throws, we retry | ||
* const res = await fetch('https://google.com'); | ||
* | ||
* if (403 === res.status) { | ||
* // don't retry upon 403 | ||
* bail(new Error('Unauthorized')); | ||
* return; | ||
* } | ||
* | ||
* const data = await res.text(); | ||
* return data.substr(0, 500); | ||
* }, | ||
* { | ||
* retries: 5, | ||
* } | ||
* ); | ||
*/ | ||
declare function AsyncRetry<TRet>(fn: AsyncRetry.RetryFunction<TRet>, opts?: AsyncRetry.Options): Promise<TRet>; | ||
declare namespace AsyncRetry { | ||
interface Options extends WrapOptions { | ||
/** | ||
* An optional function that is invoked after a new retry is performed. It's passed the | ||
* `Error` that triggered it as a parameter. | ||
*/ | ||
onRetry?: ((e: Error, attempt: number) => any) | undefined; | ||
} | ||
type RetryFunction<A> = (bail: (e: Error) => void, attempt: number) => A|Promise<A>; | ||
/** | ||
* @param bail A function you can invoke to abort the retrying (bail). | ||
* @param attempt The attempt number. The absolute first attempt (before any retries) is `1`. | ||
*/ | ||
type RetryFunction<TRet> = (bail: (e: Error) => void, attempt: number) => TRet | Promise<TRet>; | ||
} | ||
@@ -41,3 +72,3 @@ | ||
### Additional Details | ||
* Last updated: Tue, 26 Apr 2022 19:31:52 GMT | ||
* Last updated: Fri, 19 Aug 2022 20:02:26 GMT | ||
* Dependencies: [@types/retry](https://npmjs.com/package/@types/retry) | ||
@@ -47,2 +78,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by [Albert Wu](https://github.com/albertywu), [Pablo Rodríguez](https://github.com/MeLlamoPablo), and [Rafał Sawicki](https://github.com/rafsawicki). | ||
These definitions were written by [Albert Wu](https://github.com/albertywu), [Pablo Rodríguez](https://github.com/MeLlamoPablo), [Rafał Sawicki](https://github.com/rafsawicki), and [BendingBender](https://github.com/BendingBender). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6777
50
76