jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.51k stars 135 forks source link

Added a nicer method to get the number of remaining tokens #4

Closed luto closed 11 years ago

luto commented 11 years ago

This adds the getTokensRemaining-method to RateLimiter. An example can be found in the new README.md:

var RateLimiter = require('limiter').RateLimiter;
var limiter = new RateLimiter(1, 250);

// returns 1 since we did not remove a token and
// our number of tokens per interval is 1
limiter.getTokensRemaining();

Getting the number of tokens left was also possible without this method by doing limiter.tokenBucket.content, but I think having a special method for this is nicer and cleaner.

jhurliman commented 11 years ago

Merged, thanks!

luto commented 11 years ago

Nice, when will this be published to NPM?

jhurliman commented 11 years ago

It's in npm as version 1.0.3