0.0.6 • Published 7 years ago

limit-queue v0.0.6

Weekly downloads
10
License
MIT
Repository
github
Last release
7 years ago

Travis CI David npm The MIT License

NPM

limit-queue

Limit function calls with a timeout. Useful for rate limiting against services (e.g. TMDB). Supports promises.

Install

npm install --save limit-queue

or

yarn add limit-queue

Usage

With promises or async/await

import { RateLimitQueue } from "limit-queue";

const queue = new RateLimitQueue(1, 5000);

async function doSomething(): Promise<void> { 
    // Pool will start on first call
    await queue.limit(function () {
         return "Response One";  
    }); 

    await queue.limit(function () {
         return MyService.getUsers(); 
    }); 

    console.log("Done");
}

RateLimitQueue

Use this Queue as rate limit pool. cap function calls are allowed within poolMs milliseconds.

  • cap: Amount of function calls within poolMs
  • poolMs: If the cap is reached, wait for poolMs milliseconds

Test

npm test
0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago