Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rerun

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rerun

A retry library for node.js

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

rerun Build Status

A retry library for node.js.
Rerun supports promises and request.js, as you will see, the API is pretty simple.

The options and their defaults for rerun library are:

{
  retries: 3
  retryTimeout: 50
  retryFactor: 1
}
  • retries - How many times to retry before failing.
  • retryTimeout - The initial time to wait (in milliseconds) before each retry.
  • retryFactor - The multiplier after each fail to multiply retryTimeout with.

Request

Rerun use with request is the same as with request itself, but with promises.

  var request = require('rerun').request;
  var promise = request({method:'POST', url: 'http://localhost/test', retries: 2, retryTimeout: 10, retryFactor: 2});

Promise

Rerun with promises is easy too, all you need is to call the library with the function you want to retry, and if it fails, the library will try again.
Notice that if you don't want the library to retry, you can throw require('rerun').RejectError.

  var retry = require('rerun').promise;
  var promise = retry(function () { doSomething(); }, { retries: 2, retryTimeout: 10, retryFactor: 2 });

Object Proxy

Want to proxy all methods of an object with rerun functionality? Piece of cake! To proxy all methods:

  var object = { foo: function() {} }
  var retry = require('rerun').proxy;
  var proxy = retry.all(object, { retries: 2, retryTimeout: 10, retryFactor: 2 })
  var promise = proxy.foo()

To proxy only some methods:

  var object = { foo: function() {}, bar: function() {}}
  var retry = require('rerun').proxy;
  var proxy = retry.some(object, ['foo'], { retries: 2, retryTimeout: 10, retryFactor: 2 })
  var promise = proxy.foo()

Notice that proxied functions are expected to return a promise.

Keywords

FAQs

Package last updated on 19 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc