promise-thunk-retryify
v1.0.2
Published
takes any function that returns a promise and will retry it n number of tries
Downloads
4
Readme
promise-thunk-retryify
takes any function that returns a promise and will retry it n number of tries or until successful
import retryify from 'promise-thunk-retryify';
// a pretent promise-based client library to some unreliable API (for instance)
import sketchyAPI from '/path/to/unreliable/data/service.js';
let try5times = retryify(4, sketchyAPI.bind(null, {id: 1}));
try5times()
.then( doSomethingWithData )
.catch( sorryItFailed )
API
retrify(n, promiseThunk)
(int, () => Promise ) => () => Promise
where:
n
number of retry attemptspromiseThunk
: a function that when invoked (without arguments) returns a promise.
returns a function which when invoked (without arguments) returns a Promise