js-sliding-window-counter
v0.1.0
Published
Sliding Window Counter for JavaScript
Downloads
4
Readme
sliding-window-counter
Usage
var SlidingWindowCounter = require('js-sliding-window-counter');
var swc = new SlidingWindowCounter({
windowInMs: 10 * 1000,
numBuckets: 10,
keys: ['success', 'timeout']
});
setInterval(function () {
swc.success(5);
}, 200);
setInterval(function () {
swc.timeout();
}, 1000);
setInterval(function () {
console.log(swc.stats());
}, 1000);
License
MIT