pr

promise.retry

add (timeout and fail) retry for async functions

Showing:

Popularity

Downloads/wk

14

GitHub Stars

5

Maintenance

Last Commit

2yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

0.7KB

License

MIT

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

promise.retry

add (timeout and fail) retry for async functions

Build Status Coverage Status npm version npm downloads npm license

Install

$ npm i -S promise.retry

Note

this package require async/await environment.

API

const pretry = require('promise.retry')
const TimeoutError = pretry.TimeoutError
const RetryError = pretry.RetryError

pretry

const fnWithRetry = pretry(fn, options);
  • fn the original async function
  • options
    • times : int try how many times
    • timeout : int the timeout for each attempt, in ms
    • onerror : function(err, index) add extra action on an attempt error

TimeoutError

reexport from promise.timeout, see https://github.com/magicdawn/promise.timeout#api

RetryError

if all attempts failed, p = fnWithRetry(), p will be reject with a RetryError instance.

props

  • times : int same as pretry options
  • timeout : int same as pretry options
  • message : string the error message
  • errors : [err1, err2, ...] the errors

See Also

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100