UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

23 lines 647 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toArray = void 0; const Stream_1 = require("@johngw/stream-common/Stream"); async function toArray(readableStream, options) { const result = []; const promise = readableStream.pipeTo((0, Stream_1.write)((chunk) => result.push(chunk)), options); if (options?.catch) { try { await promise; return { result }; } catch (error) { return { error, result }; } } else { await promise; } return result; } exports.toArray = toArray; //# sourceMappingURL=toArray.js.map