( context: QuickJSContext, runtime: QuickJSRuntime, deadline: DeadlineTracker, timeoutMs: number, )
| 345 | }); |
| 346 | |
| 347 | const drainJobs = ( |
| 348 | context: QuickJSContext, |
| 349 | runtime: QuickJSRuntime, |
| 350 | deadline: DeadlineTracker, |
| 351 | timeoutMs: number, |
| 352 | ): void => { |
| 353 | while (runtime.hasPendingJob()) { |
| 354 | const deadlineMs = deadline.deadlineMs(); |
| 355 | if (deadlineMs !== null && Date.now() >= deadlineMs) { |
| 356 | throw new Error(timeoutMessage(timeoutMs)); |
| 357 | } |
| 358 | |
| 359 | const pending = runtime.executePendingJobs(); |
| 360 | if (pending.error) { |
| 361 | const error = context.dump(pending.error); |
| 362 | pending.error.dispose(); |
| 363 | throw toError(error); |
| 364 | } |
| 365 | } |
| 366 | }; |
| 367 | |
| 368 | const waitForDeferreds = async ( |
| 369 | pendingDeferreds: ReadonlySet<QuickJSDeferredPromise>, |
no test coverage detected