Package Exports
- rate-limit
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rate-limit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-rate-limit
Ensure that a series of functions are called with a minimum interval between each invocation.
Installation
npm install rate-limitUsage
Call rateLimit.createQueue(options) to create a queue,
where the interval between function calls is specified in milliseconds by options.interval.
Add a function to be called by calling queue.add(func).
For instance:
var rateLimit = require("rate-limit");
function getNow() {
return new Date().getTime();
}
var startTime = getNow();
function printElapsedTime() {
console.log(getNow() - startTime);
}
var queue = rateLimit.createQueue({interval: 100});
queue.add(printElapsedTime);
queue.add(printElapsedTime);
queue.add(printElapsedTime);
// Sample output:
// 0
// 105
// 206