https://github.com/rametta/limitor
⏱ A Future based rate limiter utility
https://github.com/rametta/limitor
fluture future rate-limiter utility
Last synced: about 1 year ago
JSON representation
⏱ A Future based rate limiter utility
- Host: GitHub
- URL: https://github.com/rametta/limitor
- Owner: rametta
- License: apache-2.0
- Created: 2018-10-01T11:05:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-01T14:39:26.000Z (over 7 years ago)
- Last Synced: 2025-03-28T23:53:01.481Z (about 1 year ago)
- Topics: fluture, future, rate-limiter, utility
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://npm.im/limitor)
[](http://makeapullrequest.com)
[](https://github.com/rametta/limitor/)
[](https://opensource.org/licenses/Apache-2.0)
# ⏱ Limitor
A [Future](https://github.com/fluture-js/Fluture) based rate limiter utility.
Use in combination with `parallel` to ensure rate limits are not exceeded.
## Install
`yarn add limitor`
## Usage
```js
import limitor from 'limitor'
import { of, parallel } from 'fluture'
/**
* This example demonstrates how to group an array
* of futures and ensure only the limit is executed
* every second.
*
* Below, the first 2 futures will resolve instantly
* and 1 second later the next 2 will resolve.
*/
const futures = [of(1), of(1), of(2), of(2)]
const limit = 2 // max 2 per second
const limited = limitor (futures) (limit)
parallel(Infinity, limited).fork(console.error, console.log)
```