1.0.2 • Published 6 years ago

intenta v1.0.2

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

Build Status Coverage Status Known Vulnerabilities

intenta

#intenta(fn, options) Dead simple, zero deps, async retry with built in exponential backoff.

Super simple to use

const retry = require('intenta');

function updateDB(id, data, callback){
....
}

let retryUpdateDB = retry(updateDB);

retryUpdateDB(id, data, function(err, result){
....
});

Options

You can pass some options to intenta

  • limit(Number) number of attempts to be made
  • report (Bool) On success append the number of attempts made to callback arguments
  • backoff (Function) A custom backoff function with the signature fn(attempt, error) where attempt 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.

report = true example

const retry = require('intenta');

function updateDB(id, data, callback){
....
}

let retryUpdateDB = retry(updateDB, {report: true});

retryUpdateDB(id, data, function(err, result, attemptsMade){
....
});