UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

19 lines 506 B
import { write } from '@johngw/stream-common/Stream'; export async function toArray(readableStream, options) { const result = []; const promise = readableStream.pipeTo(write((chunk) => result.push(chunk)), options); if (options?.catch) { try { await promise; return { result }; } catch (error) { return { error, result }; } } else { await promise; } return result; } //# sourceMappingURL=toArray.js.map