UNPKG

@vulcan-sql/core

Version:
33 lines 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.streamToArray = exports.arrayToStream = void 0; const stream_1 = require("stream"); const arrayToStream = (array) => { let index = 0; const stream = new stream_1.Readable({ objectMode: true, read() { if (index >= array.length) { this.push(null); return; } this.push(array[index++]); }, }); return stream; }; exports.arrayToStream = arrayToStream; const streamToArray = (stream) => { const rows = []; return new Promise((resolve, reject) => { stream.on('data', (data) => { rows.push(data); }); stream.on('end', () => { resolve(rows); }); stream.on('error', (err) => reject(err)); }); }; exports.streamToArray = streamToArray; //# sourceMappingURL=streams.js.map