JavaScript library for calculating beats per minute.
⏱️ Uses performance.now() by default, override with your own timestamps if necessary
♻️ Automatically resets when pausing between taps
import { Counter } from 'bpm-counter';
const counter = new Counter();Call the tap() method with a touch or click event.
counter.tap();Optionally you can pass timestamps in ms.
counter.tap(0);
counter.tap(500);
counter.tap(1000);
counter.tap(1500);Or initialize with an array of timestamps in ms.
const counter = new Counter([0, 500, 1000, 1500]);To read the BPM:
counter.bpm;Waiting 1.5 * average interval length will reset the counter. To reset manually:
counter.reset();yarn add bpm-counteror
npm install bpm-counter- TSDX – Zero-config CLI for TypeScript package development