# three-times

> Retry a function call

Latest version **0.3.6** (published 2014-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install three-times
pnpm add three-times
yarn add three-times
bun add three-times
```

## 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.6 |
| Published | 2014-02-11 |
| First published | 2014-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Ershag |
| Maintainers | davvo |
| Keywords | try, retry, times |

## Links

- npm: https://www.npmjs.com/package/three-times
- Repository: https://github.com/davvo/three-times
- Issues: https://github.com/davvo/three-times/issues
- npm.io page: https://npm.io/package/three-times

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.3.6 (latest) — 2014-02-11
- 0.3.5 — 2014-02-10
- 0.3.4 — 2014-02-10
- 0.3.3 — 2014-02-10
- 0.3.2 — 2014-02-10
- 0.3.1 — 2014-02-10
- 0.3.0 — 2014-02-10
- 0.2.2 — 2014-02-10
- 0.2.1 — 2014-02-10
- 0.2.0 — 2014-02-10
- 0.1.4 — 2014-02-10
- 0.1.3 — 2014-02-10
- 0.1.2 — 2014-02-10
- 0.1.1 — 2014-02-10
- 0.1.0 — 2014-02-10

## README

# three-times
Execute a function up to three times before calling the callback with the last error.

## Basic example
```javascript
var retry = require('three-times');

function foo(done) {
    done(new Error());
}

retry(foo, function (err, result) {
    if (err) {
        console.error(err);
    } else {
        console.log(result);
    }
});

```

You can override the default number of retries (3)

```javascript
// Try up to 10 times
retry(foo, function (err, result) {
    if (err) {
        console.error(err);
    } else {
        console.log(result);
    }
}, 10);

```
## Events
If the callback parameter is omitted, you can listen for events instead.

```javascript
retry(foo).on('error', function (err) {
    console.error(err);
}).on('done', function (result) {
    console.log(result);
});

```

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