- Production Ready
- Takes your promise and returns a robust-promise
- retries execution several times for extra reliability
- Simple and easy to use
- Highly configurable and flexible
- It's magic!
Simple Usage
First of all, import the library:
const robustPromise =
Let's say for example, you want to send an email. You already have a sendEmail
function that returns a promise.
Wow, that was painless!
Note that sendMail
is used here as an example only. You can use this for anything!
You can then treat your robust promise function, just like you would of treated your original function, e.g.
By default, robust-promise will try to send your email three times before rejecting. The delay between each attempt will exponentially increase according to the attempot number.
Note: robust-promise actually expects a function that returns a promise, not an actual promise. So, if you need to pass options to your function, you can wrap it in a function like so:
Advanced Usage
Let's say that you want to configure the number of retries to 6. That's easy:
Next-Level Usage
Let's say that you want to configure the number of retries to 20, and the delay to half a second. Here you go:
HARDCORE USAGE
Let's say that you are a hardcore mofo, you want to configure the number of retries to 10, with a ten sencond delay. But you are also so hard, that you don't want the delay to exponentially increase. We have you covered:
const cfg = retries: 10 delay: 10 exp: false
Contributing
Contributions are more than welcome! To contribute
- Opening a pull request
- Reporting an issue
Tests
To run the unit tests:
npm test