Create a readable Node.js stream that produces no data (or optionally blank data) or a writable stream that discards data
This can be useful for testing, fixtures, draining a stream, etc. (Example)
It's like fs.createReadStream('/dev/null')
but cross-platform.
npm install noop-stream
import stream from 'node:stream';
import {readableNoopStream} from 'noop-stream';
stream.pipeline(readableNoopStream({size: 10}), process.stdout);
import stream from 'node:stream';
import {writableNoopStream} from 'noop-stream';
stream.pipeline(process.stdin, writableNoopStream());
Create a readable Node.js stream that produces no data (or optionally blank data).
Options are passed to the stream.Readable
constructor, except for the read
option.
You can also specify a size
option, which is the size in bytes to produce. By default, it's 0
. Set it to Infinity
to make it produce data until you manually destroy the stream.
Create a writable Node.js stream that discards received data.
Options are passed to the stream.Writable
constructor, except for the write
option.
- dev-null-cli - Cross-platform
/dev/null
- random-bytes-readable-stream - Creates a readable stream producing cryptographically strong pseudo-random data