| 486 | |
| 487 | // Should only be used via an assertion helper that inspects the yielded values. |
| 488 | function unstable_flushNumberOfYields(count: number): void { |
| 489 | if (isFlushing) { |
| 490 | throw new Error('Already flushing work.'); |
| 491 | } |
| 492 | if (scheduledCallback !== null) { |
| 493 | const cb = scheduledCallback; |
| 494 | expectedNumberOfYields = count; |
| 495 | isFlushing = true; |
| 496 | try { |
| 497 | let hasMoreWork = true; |
| 498 | do { |
| 499 | hasMoreWork = cb(true, currentMockTime); |
| 500 | } while (hasMoreWork && !didStop); |
| 501 | if (!hasMoreWork) { |
| 502 | scheduledCallback = null; |
| 503 | } |
| 504 | } finally { |
| 505 | expectedNumberOfYields = -1; |
| 506 | didStop = false; |
| 507 | isFlushing = false; |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | function unstable_flushUntilNextPaint(): false { |
| 513 | if (isFlushing) { |