retryme
A more intuitive node-retry
which behaves more like async.retry
. Utilizes Backo
under the hood for backoff.
Retryme also supports async/await
now for retrying async attempt functions.
Usage
Regular usage
Here's the example of how to use retryme
in normal ways.
var Retryme = ; //// This function will have the same arguments as the function being attempted// `opts` here include `min` `max` for Backo configuration as well as `retries`.//var operation = retries: 2 min: 50 max: 10000; operation
Now if we want to ignore certain types of errors, we pass a function for configuring those cases
var retry = ; const op = retry; op;
Async/await
Support
Retryme now supports async/await
by providing .async
function to retry async attempt functions.
A simple example of how to use it is as follows:
// example of calling the method for async functions returning Promises.const readFileAsync = ;const Retryme = ; { const op = retries: 2 min: 50 max: 10000 some_ignore_function_if_exists; // Wrap a simple file read with retries. try const fileContent = await op; catcherr console; console; } // it supports async functions { if bad !== 'hola' return 'bar'; throw Error'what happened';} { const op = ; try const result = await op; catcherr console; } // it also supports thenables { await op;}
test
npm test