1. noop-stream
Create a readable Node.js stream that produces no data (or optionally blank data) or a writable stream that discards data
noop-stream
Package: noop-stream
Created by: sindresorhus
Last modified: Wed, 11 May 2022 09:05:23 GMT
Version: 1.0.0
License: MIT
Downloads: 7,386
Repository: https://github.com/sindresorhus/noop-stream

Install

npm install noop-stream
yarn add noop-stream

noop-stream

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.

Install

 npm install noop-stream

Usage

 import stream from 'stream';
import {readableNoopStream} from 'noop-stream';

stream.pipeline(readableNoopStream({size: 10}), process.stdout);
 import stream from 'stream';
import {writableNoopStream} from 'noop-stream';

stream.pipeline(process.stdin, writableNoopStream());

API

readableNoopStream(options?)

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.

writableNoopStream(options?)

Create a writable Node.js stream that discards received data.

Options are passed to the stream.Writable constructor, except for the write option.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code