# promised-simple-retry

> ## Environment

Latest version **0.3.1** (published 2018-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install promised-simple-retry
pnpm add promised-simple-retry
yarn add promised-simple-retry
bun add promised-simple-retry
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2018-12-26 |
| First published | 2017-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | leaf4monkey |
| Maintainers | leaf4monkey |
| Keywords | retry |

## Links

- npm: https://www.npmjs.com/package/promised-simple-retry
- Repository: https://github.com/leaf4monkey-npm/retry
- Homepage: https://github.com/leaf4monkey-npm/retry#readme
- Issues: https://github.com/leaf4monkey-npm/retry/issues
- npm.io page: https://npm.io/package/promised-simple-retry

## Recent versions

- 0.3.1 (latest) — 2018-12-26
- 0.3.0 — 2018-12-26
- 0.2.0 — 2017-04-27
- 0.1.1 — 2017-04-25
- 0.1.0 — 2017-04-25
- 0.0.3 — 2017-04-19
- 0.0.2 — 2017-04-19

## README

# promised-simple-retry


## Environment

node >= 8.x


## Installation

```bash
npm install --save promised-simple-retry
```


## Usage

```js
const retry = require('promised-simple-retry');

let task = function () {
    // what you want to do.
    throw new Error('always wrong.');
};

let options = {
    times: 3, // maximum retry times, default `3`
    timeout: 10 * 1000, // maximum execution milliseconds, default `10000`
    interval: 100, // interval milliseconds before execute `task()`, default `3000`
    maxInterval: 20000, // maximum interval, default `20000`,
    delay: 0, // increment to interval.
    when: err => err, // if return `false`, then stop retring.
    delay1st: true, // interval the 1st execution, default `false`
    debug: false
};

retry(task, options).then(function (res) {
    console.log('success');
}).catch(function (err) {
    console.log('failed');
    console.log(`tried ${err.tried} times.`);
    console.log(`cost ${err.cost} ms in total.`);
});
```


## Test

```bash
npm i -g mocha
npm run test
```

---
_Source: https://npm.io/package/promised-simple-retry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
