( context: QuickJSContext, runtime: QuickJSRuntime, deadlineMs: number, timeoutMs: number, )
| 296 | }); |
| 297 | |
| 298 | const drainJobs = ( |
| 299 | context: QuickJSContext, |
| 300 | runtime: QuickJSRuntime, |
| 301 | deadlineMs: number, |
| 302 | timeoutMs: number, |
| 303 | ): void => { |
| 304 | while (runtime.hasPendingJob()) { |
| 305 | if (Date.now() >= deadlineMs) { |
| 306 | throw new Error(timeoutMessage(timeoutMs)); |
| 307 | } |
| 308 | |
| 309 | const pending = runtime.executePendingJobs(); |
| 310 | if (pending.error) { |
| 311 | const error = context.dump(pending.error); |
| 312 | pending.error.dispose(); |
| 313 | throw toError(error); |
| 314 | } |
| 315 | } |
| 316 | }; |
| 317 | |
| 318 | const waitForDeferreds = async ( |
| 319 | pendingDeferreds: ReadonlySet<QuickJSDeferredPromise>, |
no test coverage detected