1. stream-exhaust
Ensure that a stream is flowing data without mutating it
stream-exhaust
Package: stream-exhaust
Created by: chrisdickinson
Last modified: Mon, 27 Jun 2022 00:46:45 GMT
Version: 1.0.2
License: MIT
Downloads: 5,410,593
Repository: https://github.com/chrisdickinson/stream-exhaust

Install

npm install stream-exhaust
yarn add stream-exhaust

stream-exhaust

Ensure that the provided stream is flowing data, even if the stream hasn't been
piped to another stream.

 var exhaustively = require('stream-exhaust');

exhaustively(fs.createReadStream(__filename))
  .on('close', () => { console.log('all done, despite being streams{1+N}!') });

Prior Art

This is based on stream-consume
by aroneous. It is a separate package because it has
different semantics:

  1. It does not call .resume() on streams2+ streams. streams2 streams monkeypatch .pipe
    when entering flowing mode; avoiding resume() avoids that fate.
  2. It does not examine ._readableState; instead it checks for the presence of ._read.

API

exhaust(Stream s) -> Stream s

Takes a stream, s, and returns it. Ensures that the stream is flowing, either by calling
.resume() if the stream is a streams1 stream, or by piping it to a "black hole" stream that
continually asks for more data.

License

MIT

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