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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?