MCPcopy
hub / github.com/yortus/asyncawait / yield_

Function yield_

src/async/makeAsyncFunc.ts:55–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54 // Create a yield() function tailored for this iterator.
55 var yield_ = expr => {
56
57 // Ensure this function is executing inside a fiber.
58 if (!Fiber.current) {
59 throw new Error(
60 'await functions, yield functions, and value-returning suspendable ' +
61 'functions may only be called from inside a suspendable function. '
62 );
63 }
64
65 // Notify waiters of the next result, then suspend the iterator.
66 if (runContext.callback) runContext.callback(null, { value: expr, done: false });
67 if (runContext.resolver) runContext.resolver.resolve({ value: expr, done: false });
68 Fiber.yield();
69 }
70
71 // Insert the yield function as the first argument when starting the iterator.
72 startupArgs[0] = yield_;

Callers 6

async.iterable.jsFile · 0.50
async.iterable.tsFile · 0.50
iteration.jsFile · 0.50
asyncMod.jsFile · 0.50

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected