UNPKG

344 BPlain TextView Raw
1import { ReadableTyped } from '../stream.model'
2
3/**
4 * Convenience function to read the whole Readable stream into Array (in-memory)
5 * and return that array.
6 */
7export async function readableToArray<T>(readable: ReadableTyped<T>): Promise<T[]> {
8 const a: T[] = []
9
10 for await (const item of readable) {
11 a.push(item)
12 }
13
14 return a
15}