(stream: ReadableStream<T>)
| 20 | } |
| 21 | |
| 22 | async function collect<T>(stream: ReadableStream<T>): Promise<T[]> { |
| 23 | const out: T[] = []; |
| 24 | const reader = stream.getReader(); |
| 25 | try { |
| 26 | while (true) { |
| 27 | const { value, done } = await reader.read(); |
| 28 | if (done) break; |
| 29 | out.push(value); |
| 30 | } |
| 31 | } finally { |
| 32 | reader.releaseLock(); |
| 33 | } |
| 34 | return out; |
| 35 | } |
| 36 | |
| 37 | async function roundTrip<E extends "utf8" | undefined>( |
| 38 | events: WorkspaceExecEvent<E>[], |
no test coverage detected