@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
24 lines (23 loc) • 672 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writableVoid = void 0;
const stream_1 = require("stream");
/**
* Use as a "null-terminator" of stream.pipeline.
* It consumes the stream as quickly as possible without doing anything.
* Put it in the end of your pipeline in case it ends with Transform that needs a consumer.
*/
function writableVoid(opt = {}) {
return new stream_1.Writable({
objectMode: true,
...opt,
write(chunk, _, cb) {
cb();
},
final(cb) {
cb();
opt.streamDone?.resolve();
},
});
}
exports.writableVoid = writableVoid;