( stream: AsyncIterable<StreamChunk>, )
| 222 | |
| 223 | /** Collect all chunks from an async iterable. */ |
| 224 | export async function collectChunks( |
| 225 | stream: AsyncIterable<StreamChunk>, |
| 226 | ): Promise<Array<StreamChunk>> { |
| 227 | const chunks: Array<StreamChunk> = [] |
| 228 | for await (const c of stream) { |
| 229 | chunks.push(c) |
| 230 | } |
| 231 | return chunks |
| 232 | } |
| 233 | |
| 234 | // ============================================================================ |
| 235 | // Type guards & extraction helpers |