Function
withTimeout
(promise: Promise<T>, timeoutMs: number, command: string)
Source from the content-addressed store, hash-verified
| 139 | } |
| 140 | |
| 141 | function withTimeout<T>(promise: Promise<T>, timeoutMs: number, command: string): Promise<T> { |
| 142 | return new Promise((resolve, reject) => { |
| 143 | const timer = setTimeout(() => { |
| 144 | reject(new TimeoutError(command, timeoutMs)); |
| 145 | }, timeoutMs); |
| 146 | |
| 147 | promise |
| 148 | .then((result) => { |
| 149 | clearTimeout(timer); |
| 150 | resolve(result); |
| 151 | }) |
| 152 | .catch((err) => { |
| 153 | clearTimeout(timer); |
| 154 | reject(err); |
| 155 | }); |
| 156 | }); |
| 157 | } |
| 158 | |
| 159 | function createTimeoutBash(bash: Bash, timeoutMs: number) { |
| 160 | return { |
Tested by
no test coverage detected