@types/async-retry
TypeScript definitions for async-retry
Last updated 2 years ago by types .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @types/async-retry 
SYNC missed versions from official npm registry.

Installation

npm install --save @types/async-retry

Summary

This package contains type definitions for async-retry (https://github.com/vercel/async-retry).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/async-retry.

index.d.ts

import { WrapOptions } from "retry";

/**
 * 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, TErr = unknown>(
    fn: AsyncRetry.RetryFunction<TRet, TErr>,
    opts?: AsyncRetry.Options<TErr> | number[],
): Promise<TRet>;

declare namespace AsyncRetry {
    interface Options<TErr = unknown> extends Omit<WrapOptions, "randomize"> {
        /**
         * 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: TErr, attempt: number) => any) | undefined;
        /**
         * Randomizes the timeouts by multiplying a factor between 1-2.
         * @default true
         */
        randomize?: boolean | undefined;
    }

    /**
     * @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, TErr = unknown> = (bail: (e: TErr) => void, attempt: number) => TRet | Promise<TRet>;
}

export = AsyncRetry;

Additional Details

  • Last updated: Wed, 02 Oct 2024 18:10:02 GMT
  • Dependencies: @types/retry

Credits

These definitions were written by Albert Wu, Pablo Rodríguez, Rafał Sawicki, and BendingBender.

Current Tags

  • 1.4.9                                ...           latest (2 years ago)
  • 1.3.0                                ...           ts2.0 (7 years ago)
  • 1.3.0                                ...           ts2.1 (7 years ago)
  • 1.3.0                                ...           ts2.2 (7 years ago)
  • 1.4.1                                ...           ts2.3 (7 years ago)
  • 1.4.1                                ...           ts2.4 (7 years ago)
  • 1.4.1                                ...           ts2.5 (7 years ago)
  • 1.4.1                                ...           ts2.6 (7 years ago)
  • 1.4.1                                ...           ts2.7 (7 years ago)
  • 1.4.1                                ...           ts2.8 (7 years ago)
  • 1.4.1                                ...           ts2.9 (7 years ago)
  • 1.4.2                                ...           ts3.0 (6 years ago)
  • 1.4.2                                ...           ts3.1 (6 years ago)
  • 1.4.2                                ...           ts3.2 (6 years ago)
  • 1.4.2                                ...           ts3.3 (6 years ago)
  • 1.4.2                                ...           ts3.4 (6 years ago)
  • 1.4.2                                ...           ts3.5 (6 years ago)
  • 1.4.3                                ...           ts3.6 (5 years ago)
  • 1.4.3                                ...           ts3.7 (5 years ago)
  • 1.4.3                                ...           ts3.8 (5 years ago)
  • 1.4.4                                ...           ts3.9 (4 years ago)
  • 1.4.5                                ...           ts4.0 (4 years ago)
  • 1.4.5                                ...           ts4.1 (4 years ago)
  • 1.4.5                                ...           ts4.2 (4 years ago)
  • 1.4.5                                ...           ts4.3 (4 years ago)
  • 1.4.5                                ...           ts4.4 (4 years ago)
  • 1.4.8                                ...           ts4.5 (2 years ago)
  • 1.4.8                                ...           ts4.6 (2 years ago)
  • 1.4.8                                ...           ts4.7 (2 years ago)
  • 1.4.9                                ...           ts4.8 (2 years ago)
  • 1.4.9                                ...           ts4.9 (2 years ago)
  • 1.4.9                                ...           ts5.0 (2 years ago)
  • 1.4.9                                ...           ts5.1 (2 years ago)
  • 1.4.9                                ...           ts5.2 (2 years ago)
  • 1.4.9                                ...           ts5.3 (2 years ago)
  • 1.4.9                                ...           ts5.4 (2 years ago)
  • 1.4.9                                ...           ts5.5 (2 years ago)
  • 1.4.9                                ...           ts5.6 (2 years ago)
  • 1.4.9                                ...           ts5.7 (2 years ago)
  • 1.4.9                                ...           ts5.8 (2 years ago)
  • 1.4.9                                ...           ts5.9 (2 years ago)
  • 1.4.9                                ...           ts6.0 (2 years ago)

14 Versions

  • 1.4.9                                ...           2 years ago
  • 1.4.8                                ...           2 years ago
  • 1.4.7                                ...           2 years ago
  • 1.4.6                                ...           3 years ago
  • 1.4.5                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           6 years ago
  • 1.4.1                                ...           7 years ago
  • 1.4.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 1
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |