# failmenot

> Run a failing function many times until it eventually passes or reaches execution limits.

Latest version **3.0.1** (published 2022-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install failmenot
pnpm add failmenot
yarn add failmenot
bun add failmenot
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2022-02-20 |
| First published | 2021-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Wylde |
| Maintainers | markwylde |

## Links

- npm: https://www.npmjs.com/package/failmenot
- npm.io page: https://npm.io/package/failmenot

## Recent versions

- 3.0.1 (latest) — 2022-02-20
- 3.0.0 — 2021-10-24
- 2.0.0 — 2021-10-24
- 1.0.1 — 2021-10-24

## README

# failmenot
Run a failing function many times until it eventually passes or reaches execution limits.

## Installation
```
npm install --save failmenot
```

## Options
```javascript
{
  maximumAttempts: null,
  maximumTime: null,
  retryDelay: 0
}
```

## Example
### Basic Usage
```javascript
const failmenot = require('failmenot');

let attemptNumber = 1;
const successAttemptNumber = await failmenot(
  {
    maximumAttempts: 3
  },

  function () {
    if (attemptNumber < 3) {
      attemptNumber = attemptNumber + 1;
      throw new Error('should fail this attempt');
    }

    return 'worked on ' + attemptNumber;
  }
);

// successAttemptNumber === 'worked on 3';
```

### Curried
```
failmenot -> options -> function -> result
```

```javascript
const failmenot = require('failmenot/curried');

let attemptNumber = 1;

const applyRetry = failmenot({
  maximumAttempts: 3
});

const runner = applyRetry(
  function (caption) {
    if (attemptNumber < 3) {
      attemptNumber = attemptNumber + 1;
      throw new Error('should fail this attempt');
    }

    return caption + ' ' + attemptNumber;
  }
);

const successAttemptNumber = await runner('worked on')

// successAttemptNumber === 'worked on 3';
```

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