limitor
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

npm PRs Welcome Open Source Love License

⏱ Limitor

A Future based rate limiter utility.

Use in combination with parallel to ensure rate limits are not exceeded.

Install

yarn add limitor

Usage

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)

/limitor/

    Package Sidebar

    Install

    npm i limitor

    Weekly Downloads

    0

    Version

    1.0.2

    License

    Apache-2.0

    Unpacked Size

    14.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • rametta