timed-reduction-counter
v2.0.0
Published
Timed Reduction Counter =======================
Downloads
3
Readme
Timed Reduction Counter
A simple incrementable counter which reduces the count periodically.
Usage
var trc = new (require('timed-reduction-counter')).TimedReductionCounter({
limit: 3, // count limit
interval: 2000 // ms
});
trc.count('key'); // 0 + 1 = 1
trc.count('key', 3) // 1 + 3 = 4
trc.isOverLimit('key'); // true (4)
// wait 2 seconds
setTimeout(() => {
trc.isOverLimit('key'); // false (3)
}, 2000);
trc.stop(); // clear timer