MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / yieldedDuring

Function yieldedDuring

__tests__/cooperative-yield.test.ts:27–32  ·  view source on GitHub ↗

* A `setImmediate` callback runs in the check phase — AFTER the microtask queue * drains. So if `await maybeYield()` did NOT cross a macrotask boundary (it was * under budget and returned a synchronously-resolved promise), a `setImmediate` * scheduled just before it has NOT fired yet. If it DID y

(maybeYield: () => Promise<void>)

Source from the content-addressed store, hash-verified

25 * This makes "did it yield?" a deterministic, non-timing assertion.
26 */
27async function yieldedDuring(maybeYield: () => Promise<void>): Promise<boolean> {
28 let macrotaskRan = false;
29 setImmediate(() => { macrotaskRan = true; });
30 await maybeYield();
31 return macrotaskRan;
32}
33
34describe('createYielder', () => {
35 it('does not yield while under the time budget', async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected