1.0.0 • Published 5 years ago
beat-filter v1.0.0
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
1.0.0
5 years ago