Name: async-throttle
Owner: ZEIT
Description: Throttling made simple, easy, async.
Created: 2016-09-30 19:19:33.0
Updated: 2018-05-15 01:00:31.0
Pushed: 2017-10-30 13:02:24.0
Size: 16
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Note: this project has been deprecated in favor of the smaller, more efficient and more zeit/async-sema. This project works and is well-tested, but we no longer favor it at ZEIT.
Throttling made simple, easy, async.
This example fetches the <title>
tag of the supplied websites,
but it processes a maximum of two at a time.
eps
t fetch = require('node-fetch')
t createThrottle = require('async-throttle')
t cheerio = require('cheerio').load
ode
t throttle = createThrottle(2)
t urls = ['https://zeit.co', 'https://google.com', /* ? */]
ise.all(urls.map((url) => throttle(async () => {
nsole.log('Processing', url)
nst res = await fetch(url)
nst data = await res.text()
nst $ = cheerio(data)
turn $('title').text()
n((titles) => console.log('Titles:', titles))
To run this example:
clone git@github.com:zeit/async-throttle
sync-throttle
install
run example