promise.retry
add (timeout and fail) retry for async functions
Last updated 2 years ago by magicdawn .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install promise.retry 
SYNC missed versions from official npm registry.

promise.retry

add (timeout and fail) retry for async functions

Build Status Coverage Status npm version npm downloads npm license

Note

this is target ES6(generator function) environment.

Install

$ npm i promise.retry --save

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

Changelog

CHANGELOG.md

See Also

License

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

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 9
Dependencies (2)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |