UNPKG

@naturalcycles/nodejs-lib

Version:
20 lines (19 loc) 550 B
import { Writable } from 'node: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. */ export function writableVoid(opt = {}) { const { objectMode = true, highWaterMark = 1 } = opt; return new Writable({ objectMode, highWaterMark, write(_chunk, _, cb) { cb(); }, final(cb) { cb(); }, }); }