leaky-bucket-queue
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

leaky-bucket-queue

An implementation of leaky bucket on top of rxjs.

Simple rate limiting are usually good enough for most scenario but they might incur unnecessary stuttering when there is attempt to make multiple call to a server API. Leaky bucket provides a burstable solution, providing rate limit while allowing bursty traffic, making application more responsive.

Installation

npm i leaky-bucket-queue

Usage

Typescript

import { LeakyBucketQueue } from 'leaky-bucket-queue';
 
const queue = new LeakyBucketQueue<string>({ burstSize: 5, period: 100 });
queue.consume().subscribe({
  next: console.log,
});
queue.enqueue('compter');
...

JavaScript

import { LeakyBucketQueue } from 'leaky-bucket-queue';
 
const queue = new LeakyBucketQueue({ burstSize: 5, period: 100 });
queue.consume().subscribe({
  next: console.log,
});
queue.enqueue('explode');
...

Package Sidebar

Install

npm i leaky-bucket-queue

Weekly Downloads

11,899

Version

0.0.2

License

MIT

Unpacked Size

22.2 kB

Total Files

21

Last publish

Collaborators

  • seanplwong