Time-budgeted cooperative yields: only awaits accmYieldToUi when at least budgetMs of wall time has elapsed since the previous yield completed.

Typical usage: construct one gate per long job, then await gate.maybeYield() inside each loop iteration.

Constructors

Accessors

Methods

Constructors

Accessors

  • get budgetMs(): number
  • Minimum wall time between yields, in milliseconds.

    Returns number

Methods

  • Marks the timeline without yielding (e.g. after an explicit paint wait). Resets the budget clock so the next maybeYield waits a full budgetMs from this point.

    Returns void

  • Yields when at least budgetMs has elapsed since the last completed yield (or since construction / mark).

    Parameters

    • yieldFn: () => Promise<void> = accmYieldToUi

      Async yield implementation. Defaults to accmYieldToUi.

    Returns Promise<boolean>

    Whether a yield actually ran.