frequency-counter
Count the number of occurrences of a repeating event per unit of time.
Installation
npm install frequency-counter --save
Usage example
Example HTTP server responding with the number of requests per minute (rpm):
const http = const Freq = // if no arguments are given a window of one minute is usedconst counter = const server = http server
API
counter = new Freq([windowSize])
Initialize the frequency counter. Optionally set a custom window size in
seconds over which the frequency should be calcuated (default: 60
).
counter.inc([amount])
Track an occurrence by incrementing a counter. Optionally provide the
amount
to increment by (default: 1
).
number = counter.freq()
Calculate and return the current frequency.
License
MIT