| 123 | * A class that delays the execution of a callback until a specified timeout period has elapsed. |
| 124 | */ |
| 125 | export class Deferral { |
| 126 | private timer?: NodeJS.Timeout; |
| 127 | |
| 128 | constructor(callback: () => void, timeout: number) { |
| 129 | this.timer = setTimeout(() => { |
| 130 | this.timer = undefined; |
| 131 | callback(); |
| 132 | }, timeout); |
| 133 | } |
| 134 | public cancel() { |
| 135 | if (this.timer) { |
| 136 | clearTimeout(this.timer); |
| 137 | this.timer = undefined; |
| 138 | } |
| 139 | } |
| 140 | } |
nothing calls this directly
no outgoing calls
no test coverage detected