()
| 15 | } |
| 16 | |
| 17 | tick(): void { |
| 18 | if (!this.isCancelled && !this.isTimeExhausted) { |
| 19 | this.timeLeftMS--; |
| 20 | if (this.timeLeftMS <= 0) { |
| 21 | this.isTimeExhausted = true; |
| 22 | const callbacks = this.callbacks.slice(); |
| 23 | this.callbacks.length = 0; |
| 24 | callbacks.forEach((callback) => { |
| 25 | try { |
| 26 | callback(); |
| 27 | } catch (error) { |
| 28 | console.error('TimeoutLatch callback error:', error); |
| 29 | } |
| 30 | }); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | cancel(): void { |
| 36 | this.isCancelled = true; |