0.0.3 • Published 3 years ago

promise-rate-limiter v0.0.3

Weekly downloads
8
License
ISC
Repository
github
Last release
3 years ago

Promise-Rate-Limiter

Limit function calls in given limits.

  • Supports multiple limits
  • Accepts every promise-returning function
  • Works with multiple promises simultaneously due to internal queue

Usage

    // node-fetch is not a dependency but highly recommended using, but every function thats returning a promise is supported
    const fetch = require('node-fetch')
    const RateLimiterClass = require('promise-rate-limiter')
    // 3 every 5 seconds but not more than 10 in 10 seconds
    const RateLimiter = new RateLimiterClass([{ limit: 3, duration: 5000 }, { limit: 10, duration: 10000 }], fetch)
    (async () => {
        for(let i = 0; i < 20; i++) {
            await RateLimiter.call(`https://jsonplaceholder.typicode.com/posts/1`)
        }
    })()
0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

1.0.1

3 years ago