mirror of
https://github.com/reality/dbot.git
synced 2024-12-12 13:59:26 +01:00
addTimeout for timers module [#494]
This commit is contained in:
parent
32b89794cb
commit
8a7333cef3
@ -34,6 +34,18 @@ var timers = function(dbot) {
|
|||||||
}
|
}
|
||||||
}.bind(this), timeout));
|
}.bind(this), timeout));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'addTimeout': function(date, callback, params) {
|
||||||
|
var now = new Date().getTime()
|
||||||
|
timeout = date.getTime() - now;
|
||||||
|
this.runningTimeouts.push(setTimeout(function() {
|
||||||
|
try {
|
||||||
|
callback.apply(callback, params);
|
||||||
|
} catch(err) {
|
||||||
|
console.log('Callback failed: ' + err);
|
||||||
|
}
|
||||||
|
}, timeout));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user