UNPKG

@naturalcycles/nodejs-lib

Version:
17 lines (16 loc) 609 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readableMapToArray = void 0; const index_1 = require("../../index"); /** * Map Readable items to array of results (in memory), * passing each result via `transformMap`. * * Warning! All results are stored in memory (no backpressure). */ async function readableMapToArray(stream, mapper = item => item, opt) { const res = []; await (0, index_1._pipeline)([stream, (0, index_1.transformMap)(mapper, opt), (0, index_1.writablePushToArray)(res)]); return res; } exports.readableMapToArray = readableMapToArray;