async-throttle

让节流变得简单、轻松、异步。「Throttling made simple, easy, async.」

  • 所有者: zeit/async-throttle
  • 平台:
  • 许可证: GNU General Public License v2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

async-throttle

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.

Build Status
XO code style
Slack Channel

Throttling made simple, easy, async.

How to use

This example fetches the <title> tag of the supplied websites,
but it processes a maximum of two at a time.

// deps
const fetch = require('node-fetch')
const createThrottle = require('async-throttle')
const cheerio = require('cheerio').load

// code
const throttle = createThrottle(2)
const urls = ['https://zeit.co', 'https://google.com', /* … */]
Promise.all(urls.map((url) => throttle(async () => {
  console.log('Processing', url)
  const res = await fetch(url)
  const data = await res.text()
  const $ = cheerio(data)
  return $('title').text()
})))
.then((titles) => console.log('Titles:', titles))

To run this example:

git clone git@github.com:zeit/async-throttle
cd async-throttle
npm install
npm run example

主要指标

概览
名称与所有者zeit/async-throttle
主编程语言Makefile
编程语言JavaScript (语言数: 1)
平台
许可证GNU General Public License v2.0
所有者活动
创建于2014-05-29 20:43:16
推送于2024-01-29 13:34:54
最后一次提交2024-01-29 11:00:48
发布数3
最新版本名称 (发布于 2014-09-29 13:01:33)
第一版名称 (发布于 2014-09-29 13:01:33)
用户参与
星数172
关注者数9
派生数15
提交数26
已启用问题?
问题数2
打开的问题数0
拉请求数4
打开的拉请求数1
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?