UNPKG

609 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.readableMapToArray = void 0;
4const index_1 = require("../../index");
5/**
6 * Map Readable items to array of results (in memory),
7 * passing each result via `transformMap`.
8 *
9 * Warning! All results are stored in memory (no backpressure).
10 */
11async function readableMapToArray(stream, mapper = item => item, opt) {
12 const res = [];
13 await (0, index_1._pipeline)([stream, (0, index_1.transformMap)(mapper, opt), (0, index_1.writablePushToArray)(res)]);
14 return res;
15}
16exports.readableMapToArray = readableMapToArray;