MCPcopy
hub / github.com/vercel/next.js / drainAndGetNext

Function drainAndGetNext

test/development/basic/next-rs-api.test.ts:126–136  ·  view source on GitHub ↗

* Drains the stream until no value is available for 100ms, then returns the next value.

(stream: AsyncIterableIterator<T>)

Source from the content-addressed store, hash-verified

124 * Drains the stream until no value is available for 100ms, then returns the next value.
125 */
126async function drainAndGetNext<T>(stream: AsyncIterableIterator<T>) {
127 while (true) {
128 const next = stream.next()
129 const result = await Promise.race([
130 new Promise((r) => setTimeout(() => r({ next }), 100)),
131 next.then(() => undefined),
132 ])
133
134 if (result) return result
135 }
136}
137
138function pagesIndexCode(text, props = {}) {
139 return `import props from "../lib/props.js";

Callers 1

Calls 4

thenMethod · 0.80
setTimeoutFunction · 0.50
rFunction · 0.50
nextMethod · 0.45

Tested by

no test coverage detected