token-bucket

0.0.1 • Public • Published

token-bucket

Function throttling via the token-bucket algorithm.

Installation

Install with npm.

$ npm install token-bucket

Install with component.

$ component install gjohnson/token-bucket

Example

This will invoke the function the first 10 times, but then throttle the next 5.

var Bucket = require('..');
 
var bucket = new Bucket(10);
var x = 15;
 
while (--x) {
  bucket.throttle(function () {
    console.log('yo!');
  });
}

Notes

This is similar to node-rate-limiter, but with more opinions and less options.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i token-bucket

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • gjohnson