mwoffliner
Version:
MediaWiki ZIM scraper
29 lines • 611 B
JavaScript
/*
* timer class that executes callback in
* timeout milliseconds and can be reset and cleared
* Used for detecting freezes
*/
class Timer {
timeout;
callback;
timer;
constructor(callback, timeout) {
this.timeout = timeout;
this.callback = callback;
this.start();
}
clear() {
if (this.timer) {
clearTimeout(this.timer);
}
}
reset() {
this.clear();
this.start();
}
start() {
this.timer = setTimeout(this.callback, this.timeout);
}
}
export default Timer;
//# sourceMappingURL=Timer.js.map