* Drains the stream until no value is available for 100ms, then returns the next value.
(stream: AsyncIterableIterator<T>)
| 124 | * Drains the stream until no value is available for 100ms, then returns the next value. |
| 125 | */ |
| 126 | async 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 | |
| 138 | function pagesIndexCode(text, props = {}) { |
| 139 | return `import props from "../lib/props.js"; |
no test coverage detected