Retries a function that returns a promise, leveraging the power of the retry module to the promises world.
There's already some modules that are able to retry functions that return promises but they were rather difficult to use or do not offer an easy way to do conditional retries.
$ npm install promise-retry
fn until the returned promise ends up fulfilled or rejected with an error different than
options argument is an object which maps to the retry module options:
retries: The maximum amount of times to retry the operation. Default is
factor: The exponential factor to use. Default is
minTimeout: The number of milliseconds before starting the first retry. Default is
maxTimeout: The maximum number of milliseconds between two retries. Default is
randomize: Randomizes the timeouts by multiplying with a factor between
2. Default is
fn function will receive a
retry function as its first argument that should be called with an error whenever you want to retry
retry function will always throw an error.
If there's retries left, it will throw a special
retry error that will be handled internally to call
If there's no retries left, it will throw the actual error passed to it.
If you prefer, you can pass the options first using the alternative function signature
var promiseRetry = ;// Simple example;// Conditional example;
$ npm test
Released under the MIT License.