#intenta(fn, options)
Dead simple, zero deps, async retry with built in exponential backoff.
const retry = require('intenta');
function updateDB(id, data, callback){
....
}
let retryUpdateDB = retry(updateDB);
retryUpdateDB(id, data, function(err, result){
....
});
You can pass some options to intenta
limit
(Number) number of attempts to be madereport
(Bool) On success append the number of attempts made to callback argumentsbackoff
(Function) A custom backoff function with the signaturefn(attempt, error)
whereattempt
is an integer > 0. It should return the number of miliseconds to backoff. You can cancel retrying by returning -1. This allows you to stop retrying early i.e does not make any sense to retry after a 404 error.
const retry = require('intenta');
function updateDB(id, data, callback){
....
}
let retryUpdateDB = retry(updateDB, {report: true});
retryUpdateDB(id, data, function(err, result, attemptsMade){
....
});