1.2.0 • Published 4 years ago

bpm-counter v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

bpm-counter

CI Workflow npm package MIT License semantic-release Maintainability Test Coverage

JavaScript library for calculating beats per minute.

:stopwatch: Uses performance.now() by default, override with your own timestamps if necessary
:recycle: Automatically resets when pausing between taps

Usage

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();

Installation

yarn add bpm-counter

or

npm install bpm-counter

Credits

  • TSDX – Zero-config CLI for TypeScript package development
1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago