# @26brains/throttled-queue-decorator

> Throttles a function to a given number per interval. Uses promises and decorates original function.

Latest version **1.0.2** (published 2019-10-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @26brains/throttled-queue-decorator
pnpm add @26brains/throttled-queue-decorator
yarn add @26brains/throttled-queue-decorator
bun add @26brains/throttled-queue-decorator
```

## 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.0.2 |
| Published | 2019-10-26 |
| First published | 2019-10-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Damien Hampton |
| Maintainers | damienhampton |

## Links

- npm: https://www.npmjs.com/package/@26brains/throttled-queue-decorator
- npm.io page: https://npm.io/package/@26brains/throttled-queue-decorator

## Recent versions

- 1.0.2 (latest) — 2019-10-26
- 1.0.1 — 2019-10-26
- 1.0.0 — 2019-10-26

## README

# Throttled Queue Decorator

## Install
`npm i @26brains/throttled-queue-decorator`

## Usage

```javascript
const { createThrottle } = require('throttled-queue-decorator');

const throttle = createThrottle(2, 1000); // 2 requests per 1000 milliseconds

const func = (id) => axios.get(`http://example.com/record/${id}`);
const throttledFunc = throttle(func);

const main = async () => {
  return await Promise.all([
    throttledFunc(1),
    throttledFunc(2),
    throttledFunc(3),
  ])
}
//third request will be delayed by 1 second
main();
```

# Tests

`npm test`

# Example

`node example/example.js`

## Credits

Use of single `setTimeout()` event copied from https://github.com/shaunpersad/throttled-queue.

---
_Source: https://npm.io/package/@26brains/throttled-queue-decorator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
