nouveau-theatre-de-besancon/node_modules/collect-stream/index.js

16 lines
325 B
JavaScript
Raw Permalink Normal View History

2024-09-20 10:32:49 +02:00
import { default as concat } from 'concat-stream';
import { default as once } from 'once';
export default function collect(stream, opts, fn) {
if (typeof opts === 'function') {
fn = opts;
opts = {};
}
fn = once(fn);
stream.on('error', fn);
stream.pipe(concat(opts, data => {
fn(null, data);
}));
};