npm.io
1.0.1 • Published 7 years ago

node-rate-counter

Licence
MIT
Version
1.0.1
Deps
0
Size
5 kB
Vulns
0
Weekly
0

node-rate-counter

Build Status npm version npm

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


Keywords