UNPKG

tsbase

Version:

Base class libraries for TypeScript

31 lines 928 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Timer = void 0; class Timer { constructor(interval) { this.AutoReset = false; this.Enabled = false; this.Elapsed = new Array(); interval ? this.Interval = interval : this.Interval = 0; } async Start() { return await new Promise((resolve) => { this.Enabled = this.Elapsed.length >= 1; const executer = setInterval(async () => { this.Elapsed.forEach(item => item()); if (!this.AutoReset) { this.Enabled = false; } if (!this.Enabled) { clearInterval(executer); resolve(); } }, this.Interval); }); } Stop() { this.Enabled = false; } } exports.Timer = Timer; //# sourceMappingURL=Timer.js.map