NineSec Team Shell
Server IP : 92.205.26.207  /  Your IP : 216.73.216.16
Web Server : Apache
System : Linux 207.26.205.92.host.secureserver.net 4.18.0-553.60.1.el8_10.x86_64 #1 SMP Thu Jul 10 04:01:16 EDT 2025 x86_64
User : zikryat ( 1002)
PHP Version : 8.3.23
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/zikryat/public_html/node_modules/character-parser/../async-retry/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zikryat/public_html/node_modules/character-parser/../async-retry/README.md
# async-retry

Retrying made simple, easy, and async.

## Usage

```js
// Packages
const retry = require('async-retry');
const fetch = require('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,
  }
);
```

### API

```js
retry(retrier : Function, opts : Object) => Promise
```

- The supplied function can be `async` or not. In other words, it can be a function that returns a `Promise` or a value.
- The supplied function receives two parameters
  1. A `Function` you can invoke to abort the retrying (bail)
  2. A `Number` identifying the attempt. The absolute first attempt (before any retries) is `1`.
- The `opts` are passed to `node-retry`. Read [its docs](https://github.com/tim-kos/node-retry)
  - `retries`: The maximum amount of times to retry the operation. Default is `10`.
  - `factor`: The exponential factor to use. Default is `2`.
  - `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.
  - `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.
  - `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `true`.
  - `onRetry`: an optional `Function` that is invoked after a new retry is performed. It's passed the `Error` that triggered it as a parameter.

## Authors

- Guillermo Rauch ([@rauchg](https://twitter.com/rauchg)) - [Vercel](https://vercel.com)
- Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [Vercel](https://vercel.com)

NineSec Team - 2022