promise-retryable
Retries a function which returns a promise, with configurable backoff and attempts.
Installation
npm install promise-retryable
yarn add promise-retryable
Usage
The final resolved value would be an object containing the value and attempt in which it got resolved.
retry(fn).then({ value, attempt })
-
With default settings
const fn = -
With user defined settings
const fn =/**default values:minWait = 1000,maxWait = 30000,attempts = 4**/const minWait = 2000maxWait = 10000attempts = 5fn
You can also inject a backoff function as the last argument with the following signature. The default implementation backs off in multiple of 2 with max time capped at maxWait provided.
{ // calculate sleepInterval based on the arguments return sleepInterval} fn
License
MIT. See LICENSE