co-limits
v0.0.3
Published
limits.js version that can be used with co
Downloads
8
Maintainers
Readme
co-limits
co-limits extends limits.js with a 'co' method. With this you can use limits.js in an co container.
Sample
var co = require('co');
var colimits = require('co-limits');
var start = Date.now();
var c = colimits({
secondly: 1, // allow 1 call per second
minutely: 2 // allow 2 calls per minute
}).co();
co(function* () {
yield c;
console.log(Date.now() - start, 'ms'); // Output: 0 ms
yield c;
console.log(Date.now() - start, 'ms'); // Output: 1000 ms
yield c;
console.log(Date.now() - start, 'ms'); // Output: 60000 ms
})();
Installation
npm install co-limits
License
Copyright (c) 2014 Simon Kusterer Licensed under the MIT license.