Skip to content

brentropy/mulligan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mulligan

npm Travis Code Climate Code Climate Coverage

A simple JavaScript helper for adding a retry interval for rejected promises.

Installation

$ npm install mulligan --save

Usage

Mulligan works with any promise library that implements an ES6 style promise constructor. It works by wrapping a resolver function.

var Promise = require('any-supported-promise-library')
var mulligan = require('mulligan')

var promise = new Promise(mulligan(
  5, // the number of times to try before rejecting
  1000, // the number of milliseconds to wait between retries
  function (resolve, reject) {} // promise resolver
))

Conditional Retries

Mulligan takes a function as an optional fourth argument to support conditional retries. It receives the error from the last rejection as the first argument. If the function returns true it will move on the the next attempt. If the function returns false the promise will be rejected immediately.

About

A simple JavaScript helper for adding a retry interval for rejected promises.

Resources

Stars

Watchers

Forks

Packages

No packages published