Have ideas to improve npm?Join in the discussion! »

    bpm-counter
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.0 • Public • Published

    bpm-counter

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

    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

    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

    Keywords

    none

    Install

    npm i bpm-counter

    DownloadsWeekly Downloads

    0

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    35.8 kB

    Total Files

    17

    Last publish

    Collaborators

    • avatar