Share your code. Components are building blocks, you are the architect.

global/promise-retry
v0.0.4
0.0.4
0.0.3
0.0.2
0.0.1
MIT
PUBLIC
6
1     DEPENDENCIES
retry^0.10.0
Build: pass
BuildPass
Build Status: pass

Retries a function that returns a promise

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use global/promise-retry in your project
npm i @bit/amit.utils.global.promise-retry
Copied

promiseRetry (fn:fn, options:options)

Retries a function that returns a promise

Example

```js
 promiseRetry((retry, number) => promiseFunction().catch(retry),{retries:3})
 .then((result) => console.log(result)).catch(err => console.log(err))
```

Arguments

fn: fn

options: options

The options argument is an object which maps to the retry module options: retries: Max retries. Default is 10. factor: The exponential factor to use. Default is 2. minTimeout: The number of milliseconds before starting the first retry. Default is 1000. maxTimeout: The maximum number of milliseconds between two retries. Default is Infinity. randomize: Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.

Test Summary


promiseRetry should return success on first tryPass
promiseRetry should not retry on fail if retry not calledPass
promiseRetry should not retry on rejection if retry count is set to 0Pass
promiseRetry should reject the promise if max number of retries has exceededPass
promiseRetry Dont retry if promise was successfulPass