# delta-counter

> [![npm Build/Test](https://github.com/lmzdev/delta-counter/actions/workflows/node.js.yml/badge.svg)](https://github.com/lmzdev/delta-counter/actions/workflows/node.js.yml)

Latest version **1.1.2** (published 2023-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install delta-counter
pnpm add delta-counter
yarn add delta-counter
bun add delta-counter
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-01-09 |
| First published | 2023-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | lmzdev |
| Keywords | counter, timer, interval, setInterval |

## Links

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

## Recent versions

- 1.1.2 (latest) — 2023-01-09
- 1.1.1 — 2023-01-09
- 1.1.0 — 2023-01-08
- 1.0.2 — 2023-01-07
- 1.0.1 — 2023-01-07

## README

# delta-counter
[![npm Build/Test](https://github.com/lmzdev/delta-counter/actions/workflows/node.js.yml/badge.svg)](https://github.com/lmzdev/delta-counter/actions/workflows/node.js.yml)

Count average events per second in a timespan. Just like adding a tally counter to ```setInterval()```.

## Example/Concept
```js
import * as Mqtt from 'mqtt'
import { DeltaCounter } from 'delta-counter'

const client = Mqtt.connect()
client.on('connect', () => {
    client.subscribe('#')
}

const intervalSec = 5
const dc = new DeltaCounter(intervalSec, (eventsPerSecond) => {
    console.log("Average number of messages per second: "+eventsPerSecond)
}).start()

client.on('message', () => dc.tick())

```

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