@types/async-retry
- Version 1.4.9
- Published
- 6.43 kB
- 1 dependency
- MIT license
Install
npm i @types/async-retry
yarn add @types/async-retry
pnpm add @types/async-retry
Overview
TypeScript definitions for async-retry
Index
Functions
function AsyncRetry
AsyncRetry: <TRet, TErr = unknown>( fn: AsyncRetry.RetryFunction<TRet, TErr>, opts?: AsyncRetry.Options<TErr> | number[]) => Promise<TRet>;
Retrying made simple, easy, and async.
Example 1
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, } );
Interfaces
interface Options
interface Options<TErr = unknown> extends Omit<WrapOptions, 'randomize'> {}
property onRetry
onRetry?: ((e: TErr, attempt: number) => any) | undefined;
An optional function that is invoked after a new retry is performed. It's passed the
Error
that triggered it as a parameter.
property randomize
randomize?: boolean | undefined;
Randomizes the timeouts by multiplying a factor between 1-2. true
Type Aliases
type RetryFunction
type RetryFunction<TRet, TErr = unknown> = ( bail: (e: TErr) => void, attempt: number) => TRet | Promise<TRet>;
Parameter bail
A function you can invoke to abort the retrying (bail).
Parameter attempt
The attempt number. The absolute first attempt (before any retries) is
1
.
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/async-retry
.
- Markdown[](https://www.jsdocs.io/package/@types/async-retry)
- HTML<a href="https://www.jsdocs.io/package/@types/async-retry"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3844 ms. - Missing or incorrect documentation? Open an issue for this package.