(fn: ConditionFunction)
| 260 | }, |
| 261 | |
| 262 | async waitUntil(fn: ConditionFunction) { |
| 263 | await new Promise<void>((resolve, reject) => { |
| 264 | const check: CheckerFunction = state => { |
| 265 | if (fn(state)) { |
| 266 | pending.delete(check); |
| 267 | pendingRejection.delete(check); |
| 268 | resolve(); |
| 269 | } |
| 270 | }; |
| 271 | const error = new ErrorWithStack( |
| 272 | 'Process exited', |
| 273 | continuousRun.waitUntil, |
| 274 | ); |
| 275 | pendingRejection.set(check, () => reject(error)); |
| 276 | pending.add(check); |
| 277 | }); |
| 278 | }, |
| 279 | }; |
| 280 | |
| 281 | return continuousRun; |