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

ritry

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ritry

## Install ``` $ npm install --save ritry ```

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ritry

Install

$ npm install --save ritry

Usage

The following code throws an error after 4 retries.

import { ritry } from 'ritry'

function promiseFunction() {
  return new Promise((_, reject) => {
    setTimeout(() => reject(new Error('fail')), 500)
  })
}

ritry(promiseFunction, { retry: 4 }).catch((err) => {
  console.error(err)
})

you can gradually increase the duration.

import { ritry } from 'ritry'

function promiseFunction({ retryCount }) {
  const duration = 1000 + retryCount * 200
  return new Promise((_, reject) => {
    setTimeout(() => reject(new Error('fail')), duration)
  })
}

ritry(promiseFunction, { retry: 4 }).catch((err) => {
  console.error(err)
})
declare type Callback<T> = () => Promise<T>;
declare type Options = {
  retry?: number;
};
export declare function ritry<T>(callback: Callback<T>, options?: Options): Promise<T>;

Options

retry

default: 1
You can change the number of retries

License

MIT

Keywords

FAQs

Package last updated on 14 May 2019

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