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

@types/retry

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/retry

TypeScript definitions for retry

  • 0.12.5
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
decreased by-5.95%
Maintainers
1
Weekly downloads
 
Created

What is @types/retry?

The @types/retry package provides TypeScript type definitions for the 'retry' npm package, which is a utility for retrying operations that might fail. It allows developers to implement retry logic with various strategies and options, making it easier to handle transient failures in applications. The types package doesn't add functionality but offers type support for TypeScript users of 'retry'.

What are @types/retry's main functionalities?

Creating a retry operation

This feature allows you to create a retry operation. You can specify the operation you want to retry, such as a network request. The `attempt` method is used to try the operation, and `retry` is called if the operation fails, until the maximum number of attempts is reached.

import * as retry from 'retry';

const operation = retry.operation();

operation.attempt((currentAttempt) => {
  // Your operation here, e.g., a network request
  if (networkError) {
    if (operation.retry(networkError)) {
      return;
    }
    // Handle the network error after max retries
  }
});

Customizing retry options

This feature demonstrates how to customize the retry operation with specific options. You can set the maximum number of retries, the exponential backoff factor, minimum and maximum timeout between retries, and whether to randomize the retry intervals.

import * as retry from 'retry';

const operation = retry.operation({
  retries: 5, // Maximum number of attempts
  factor: 2, // The exponential factor
  minTimeout: 1 * 1000, // The number of milliseconds before starting the first retry
  maxTimeout: 60 * 1000, // The maximum number of milliseconds between two retries
  randomize: true, // Randomizes the timeouts by multiplying with a factor between 1 to 2
});

Other packages similar to @types/retry

FAQs

Package last updated on 07 Nov 2023

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