# node-rate-counter

> calculate the a rate given over any interval with a retention period.

Latest version **1.0.1** (published 2019-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-rate-counter
pnpm add node-rate-counter
yarn add node-rate-counter
bun add node-rate-counter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-11-20 |
| First published | 2019-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Aaron Lynn |
| Maintainers | gigaclank |
| Keywords | node, rate, counter |

## Links

- npm: https://www.npmjs.com/package/node-rate-counter
- Repository: https://github.com/Gigaclank/node-rate-counter
- Homepage: https://github.com/Gigaclank/node-rate-counter#readme
- Issues: https://github.com/Gigaclank/node-rate-counter/issues
- npm.io page: https://npm.io/package/node-rate-counter

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-11-20
- 1.0.0 — 2019-11-19

## README

# node-rate-counter
[![Build Status](https://travis-ci.com/Gigaclank/node-rate-counter.svg?branch=master)](https://travis-ci.com/Gigaclank/node-rate-counter)
[![npm version](https://badge.fury.io/js/node-rate-counter.svg)](https://badge.fury.io/js/node-rate-counter)
[![npm](https://img.shields.io/npm/dm/node-rate-counter.svg)]()

Calculate the incomming rate of anything.

# Installation
``` bash
npm install node-rate-counter
```
# Usage
``` js
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](https://johnresig.com/blog/accuracy-of-javascript-time/)** for more detail

---
<p align="center" z-index = "-1">
  <img src="https://avatars2.githubusercontent.com/u/12459794?s=200&v=4"/>
</p>

---
_Source: https://npm.io/package/node-rate-counter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
