1.0.8 • Published 6 years ago

easy-retry-promise-native v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Overview

The premise behind the library is to be able to make retry calls with minimal fuss using native promises. The library will retry with increasing timeouts until your max timeout is reached and then the maximum number of attempts is also reached.

Usage

When creating a retry, it will take a function that you wish to retry, and optional parameters and then a function will be returned to you. Once you are ready to execute you can invoke the function and the retry will begin.

The basic usage is that we should be able to make a simple retry

const retry = require('easy-retry-promise-native')

const myFunction = () => {
  // do something
  return Promise.resolve('yay')
}

retry(myFunction)()
  .then((result) => {
    console.log(result)
  })

Options

There are a few options that can be set

nametypedefaultdescription
maxAttemtpsint3the maximum number of attempts that the library will make
minTimeoutint100The smallest amount of time a delay will occur between attempts
maxTimeoutint1000The max amount of time a delay will occur between attempts

NOTE: you can set the maxAttempts to either 'inf' or 'infinite' to have it retry forever

you can pass options as an object when creating the retry

const func = retry(myFunction, { maxAttempts: 10 })
func()
1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago