@tcort/leakybucket

1.0.2 • Public • Published

leakybucket

simple and efficient leaky bucket implementation.

Example

This leaky bucket allows up to 2 drips in a 5 second window.

'use strict';

const LeakyBucket = require('leakybucket');

                               /* capacity */ /* window     */
const bucket = new LeakyBucket(      2       ,   5000 /* ms */);

setInterval(() => bucket.drip(), 1000); // simulate hits every 1 second

// throws a LEAKYBUCKET_FULL error after 3 seconds

Readme

Keywords

Package Sidebar

Install

npm i @tcort/leakybucket

Weekly Downloads

6

Version

1.0.2

License

ISC

Unpacked Size

4.38 kB

Total Files

7

Last publish

Collaborators

  • tcort