@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
18 lines (16 loc) • 483 B
text/typescript
import { Writable } from 'stream'
import { TransformOpt } from '../stream.model'
/**
* 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?: TransformOpt): Writable {
return new Writable({
objectMode: true,
...opt,
write(chunk, _encoding, cb) {
cb()
},
})
}