react-notification-system
Version:
A React Notification System fully customized
27 lines (21 loc) • 482 B
JavaScript
var Helpers = {
Timer: function(callback, delay) {
var timerId;
var start;
var remaining = delay;
this.pause = function() {
clearTimeout(timerId);
remaining -= new Date() - start;
};
this.resume = function() {
start = new Date();
clearTimeout(timerId);
timerId = setTimeout(callback, remaining);
};
this.clear = function() {
clearTimeout(timerId);
};
this.resume();
}
};
module.exports = Helpers;