# async-throttle

> Throttle asynchronous Promise-based tasks

Latest version **1.1.0** (published 2017-02-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-throttle
pnpm add async-throttle
yarn add async-throttle
bun add async-throttle
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-02-16 |
| First published | 2016-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rauchg, tootallnate |

## Links

- npm: https://www.npmjs.com/package/async-throttle
- Repository: https://github.com/zeit/async-throttle
- Homepage: https://github.com/zeit/async-throttle#readme
- Issues: https://github.com/zeit/async-throttle/issues
- npm.io page: https://npm.io/package/async-throttle

## Recent versions

- 1.1.0 (latest) — 2017-02-16
- 1.0.0 — 2016-10-26
- 0.0.1 — 2016-09-30

## README

# async-throttle

[![Build Status](https://travis-ci.org/zeit/async-throttle.svg?branch=master)](https://travis-ci.org/zeit/async-throttle)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![Slack Channel](https://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/)

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**.

<p align="center">
  <img src="https://cldup.com/QstcrynRNT.gif" />
</p>

```js
// 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
```

---
_Source: https://npm.io/package/async-throttle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
