https://github.com/poetic/retryable-promise
A simple promise retry implementation that will retry a promise X times before rejecting.
https://github.com/poetic/retryable-promise
Last synced: 2 months ago
JSON representation
A simple promise retry implementation that will retry a promise X times before rejecting.
- Host: GitHub
- URL: https://github.com/poetic/retryable-promise
- Owner: poetic
- Created: 2014-09-14T20:43:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-09T19:11:06.000Z (over 8 years ago)
- Last Synced: 2025-03-24T20:22:55.696Z (3 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# retryable-promise [](https://travis-ci.org/poetic/retryable-promise)
A simple promise retry implementation that will retry a promise X times before rejecting.
**Works with any compliant promise library in Node or the browser;**
## Installation
* `npm install --save retryable-promise`
## Usage
You pass in a function that returns a promise as the first argument and it will retry it up to 3 times until
failing. It returns a promise that you can chain from like normal.You can also optionally pass in an options object as the second argument. It accepts a `maxRetry` key to alter how many times it will retry the promise before failing. By default, a retry will be attempted immediately however, you can use the `timeout` key with a value of milliseconds to wait before retrying.
For example, to retry a promise up to 5 times and wait 1 second between each attempt:
```
return retryablePromise(yourPromise(), {
maxRetries: 5,
timeout: 1000
});
```## Running Tests
* `npm test`