Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantdhiman committed Jun 2, 2018
1 parent ccc8f26 commit ae4c2ef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
@@ -1,10 +1,15 @@
# retry-as-promised

Retry promises when they fail, based upon [any-promise](https://github.com/kevinbeaty/any-promise).

## Installation

```sh
$ npm install --save retry-as-promised
$ yarn add retry-as-promised
```

Retry a failed promise
## Configuration

```js
var retry = require('retry-as-promised');
Expand All @@ -17,19 +22,19 @@ return retry(function (options) {
return promise;
}, {
max: 3, // maximum amount of tries
timeout: 10000 // throw if no response or error within milisecnd timeout, default: undefined,
timeout: 10000 // throw if no response or error within millisecond timeout, default: undefined,
match: [ // Must match error signature (ala bluebird catch) to continue
Sequelize.ConnectionError,
'SQLITE_BUSY'
],
backoffBase: 1000 // Initial backoff duration in ms. Default: 100,
backoffExponent: 1.5 // Exponent to increase backoff each try. Default: 1.1
report: warningFn, // the function used for reporting; must have a (string, object) argument signature, where string is the message that will passed in by retry-as-promised, and the object will be this configuration object + the $current property
name: 'SourceX', // if user supplies string, it will be used when composing error/reporting messages; else if retry gets a callback, uses callback name in erroring/reporting; else (default) uses litteral string 'unknown'
Promise: Promise // Promise instance to create promises with
name: 'SourceX' // if user supplies string, it will be used when composing error/reporting messages; else if retry gets a callback, uses callback name in erroring/reporting; else (default) uses literal string 'unknown'
});
```

## Tested with

- Bluebird
- Q

0 comments on commit ae4c2ef

Please sign in to comment.