1.0.0 • Published 5 years ago

beat-filter v1.0.0

Weekly downloads
3
License
-
Repository
-
Last release
5 years ago

Beat Filter

Example

const bf = beatFilter({
    every: 500
});

bf.attempt(({ date, isLast }) => {
    var [ window_width, window_height ] = process.stdout.getWindowSize();
    let time_output = date.getSeconds().toString() + ":";
    time_output += date.getMilliseconds().toString() + " ";

    if (isLast) {
        console.log("last!!!")
        process.stdout.write(time_output);
        console.log(window_width);
    }
    else {
        process.stdout.write(time_output);
        console.log(window_width);
    }
});

Explanation

this should allow events every 500 milliseconds except for the last event which will also be called after the interval.

Event 1: 0 -> 0 Event 2: 200 -> 500 Event 2: 600 -> 1000 Event 3: 1100 -> Event 3: 1139 -> 1500