@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
20 lines (19 loc) • 583 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writablePushToArray = void 0;
const stream_1 = require("stream");
/**
* Will push all results to `arr`, will emit nothing in the end.
*/
function writablePushToArray(arr, opt = {}) {
return new stream_1.Writable({
objectMode: true,
...opt,
write(chunk, _, cb) {
arr.push(chunk);
// callback to signal that we processed input, but not emitting any output
cb();
},
});
}
exports.writablePushToArray = writablePushToArray;