UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

35 lines (34 loc) 1.11 kB
function _define_property(obj, key, value) { if (key in obj) Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); else obj[key] = value; return obj; } class Timer { constructor(callback, delay){ _define_property(this, "timerID", void 0); _define_property(this, "start", void 0); _define_property(this, "remaining", void 0); _define_property(this, "callback", void 0); _define_property(this, "pause", ()=>{ if (this.start) { window.clearTimeout(this.timerID); this.remaining -= Date.now() - this.start; } }); _define_property(this, "run", ()=>{ this.start = Date.now(); if (this.timerID) window.clearTimeout(this.timerID); this.timerID = window.setTimeout(this.callback, this.remaining); }); this.remaining = delay; this.callback = callback; } } const utils_Timer = Timer; export default utils_Timer; //# sourceMappingURL=Timer.js.map