util-retry
v1.0.0
Published
A thin and lightweight wrapper for calling async function no more than specific times before returning an error
Downloads
9
Readme
A thin and lightweight utilty to wrap an async function and makes it retryable. If all retires failed, the last attampt error will be sent back.
Example #1
const retry = require('util-retry');
var request = retry(api); // try calling api function 3 times
request({...options as required by the api}, callback );Other Examples
const retry = require('util-retry');
// try calling api function 5 times
var request = retry(5, api);
// same as above
var request = retry({times: 5}, api);
// set 10 seconds to wait between retries.
var request = retry({times: 5, wait: 10000}, api);
retry([options], task)
options:<Number>|<Object>- times: Unsigned int. Retry limitation. Default: 3.
- wait : Milliseconds. The interval time to wait between retries. Default: 0
If options is a number, it means
timestaskNormal async function, nodejs style callback is always the last argument.
