New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-iterator-retry

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-iterator-retry

Retry async iterators.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31
increased by342.86%
Maintainers
1
Weekly downloads
 
Created
Source

async-iterator-retry npm version

Retry async iteraotrs.

Overview

Like promise-retry but for async iterators, also based on retry.

Usage

const asyncIteratorRetry = require('async-iterator-retry')

const options = {
  retries: 10, // The maximum amount of times to retry the operation. Default is 10.
  factor: 2, // The exponential factor to use. Default is 2.
  minTimeout: 1000, // The number of milliseconds before starting the first retry. Default is 1000.
  maxTimeout: Infinity, // The maximum number of milliseconds between two retries. Default is Infinity.
  randomize: false // Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.
}

const iteratorWithRetry = asyncIteratorRetry(async function * (retry, attempt) {
  if (attempt > 1) {
    console.log(`Retrying, attempt ${attempt}...`)
  }

  const iterator = getSomeIterator()

  try {
    yield * iterator
  } catch (err) {
    if (err.code === 'ETIMEDOUT') {
      yield * retry(err)
    }

    throw err
  }

}, options)

for await const (item of myIteratorWithRetry) {
  console.log(item)
}

FAQs

Package last updated on 07 Mar 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