node-rate-counter
v1.0.1
Published
calculate the a rate given over any interval with a retention period.
Downloads
6
Readme
node-rate-counter
Calculate the incomming rate of anything.
Installation
npm install node-rate-counter
Usage
let counter = new rateCounter()
setInterval(() => {
counter.increment()
rateCounter.clean_up(120000)//hold the last 120 seconds worth of data
console.log(counter.rate)
}, 100) //increment counter every 100ms (i.e rate of 10/s)
N.B.
This module has a margin of error when using node js timers due to the nature of of node js. See this link for more detail