Skip to content

Instantly share code, notes, and snippets.

@dreadjr
Created January 31, 2013 23:58
Show Gist options
  • Save dreadjr/4687859 to your computer and use it in GitHub Desktop.
Save dreadjr/4687859 to your computer and use it in GitHub Desktop.
var limiter = new RateLimiter(5, 'minute');var n = 0;
var x = 0;
console.log('0 minute');
setInterval(function() {
console.log((++x)+' minute');
}, 60000);
setInterval(function() {
limiter.removeTokens(1, function(err, remainingRequests) {
console.log('request'+(n++)+' :: '+remainingRequests);
});
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment