make-retryable
Version:
Makes your function retryable
34 lines (21 loc) • 1.1 kB
Markdown
[](https://travis-ci.org/alanclarke/make-retryable)
[](https://david-dm.org/alanclarke/make-retryable)
[](https://coveralls.io/github/alanclarke/make-retryable?branch=master)
[](http://standardjs.com/)
Makes your function retryable
16 LOC, 100% test coverage, no deps
`npm install make-retryable`
```js
;(async () => {
const makeRetryable = require('make-retryable')
const attempts = 2
const retryable = makeRetryable(fn, attempts /* defauts to 3 */)
// Will retry until the promise resolves or attempts reaches zero
await retryable('https://alz.io')
// Respects input arguments and return values
console.log(await retryable(1, 2, 3) === await retryable(1, 2, 3)) // true
})()
```