igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
48 lines (47 loc) • 963 B
JavaScript
import timers from "node:timers";
class Timer {
static TIMERS = /* @__PURE__ */ new Set();
timeout;
constructor(timeout) {
this.timeout = timeout;
this.timeout.unref();
Timer.TIMERS.add(this);
}
static setTimeout(runnable, timeoutMillis) {
const timer = new Timer(
setTimeout(() => {
runnable();
this.TIMERS.delete(timer);
}, timeoutMillis)
);
return timer;
}
static setInterval(runnable, timeoutMillis) {
const timer = new Timer(
setInterval(() => {
runnable();
this.TIMERS.delete(timer);
}, timeoutMillis)
);
return timer;
}
/**
* Cancel all pending timers.
*/
static cancelAll() {
this.TIMERS.forEach((timer) => {
timer.cancel();
});
}
/**
* Cancel this timer.
*/
cancel() {
timers.clearTimeout(this.timeout);
Timer.TIMERS.delete(this);
}
}
export {
Timer as default
};
//# sourceMappingURL=timer.js.map