promise-retry

v0.0.4arrow_drop_down
v0.0.4
v0.0.3
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
6
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 years ago
SIZE
N/A
Retries a function that returns a promise
Install promise-retry as a package?
Copied
npm i @bit/amit.utils.global.promise-retry
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
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 try

Pass

promiseRetry should not retry on fail if retry not called

Pass

promiseRetry should not retry on rejection if retry count is set to 0

Pass

promiseRetry should reject the promise if max number of retries has exceeded

Pass

promiseRetry Dont retry if promise was successful

Pass
Help and resources