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

async-each-series-throttle

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-each-series-throttle

Iterate through items in series but throttle iteratee execution

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

async-each-series-throttle Build Status dependencies Status

Iterate through items in series but throttle iteratee execution

Usage

import eachSeriesThrottle from 'async-each-series-throttle'

const items = [0, 1, 2, 3, 4]

// Number in ms to throttle calls to iteratee
const wait = 1000

// Called only once every ~1000ms at minimum
const iteratee = (item, cb) => {
  // Do some async work and callback when done
  //
  // If this takes _more than_ 1000ms then iteratee will be called again
  // immediately after cb is called.
  //
  // If this takes _less than_ 1000ms then iteratee will be called again after
  // ~1000ms have elapsed since the last time it was called.
  setTimeout(() => cb(null, item + 1), 500)
}

// Optional callback after everything is done
const callback = (err, results) => {
  // All done, after ~4000ms or more
  // results is [1, 2, 3, 4, 5]
}

eachSeriesThrottle(items, iteratee, wait, callback)

Keywords

FAQs

Package last updated on 17 Aug 2017

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