Wrap a function to support retry.
npm install retry-func
const retryFunc = require('retry-func')
async function someFunc(someArg1, someArg2, ...) {
...
}
const result = await retryFunc({maxTries: 3})(func)('arg1, 'arg2', ...)
- type: (options?) => (func) => func
- options:
- maxTries?: Number = 3
- shouldRetry?: (error) => Boolean - always return true by default
- beforeTry?: ({tries, args}) => Void
- tries: Number - current try count, from 1
- args: Array
- afterTry?: ({tries, args, success, result, error, willRetry}) => Void
- tries: Number - current try count, from 1
- args: Array
- success: Boolean
- result?: Any
- error?: Error
- willRetry: Boolean
MIT