Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-exhaust

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-exhaust

Ensure that a stream is flowing data without mutating it

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
decreased by-1.94%
Maintainers
1
Weekly downloads
 
Created

What is stream-exhaust?

The stream-exhaust npm package is used to ensure that a stream is fully consumed. This can be useful in scenarios where you need to make sure that all data from a stream is read, even if you don't need to process the data itself.

What are stream-exhaust's main functionalities?

Exhausting a Readable Stream

This feature ensures that a readable stream is fully consumed. The example demonstrates creating a readable stream from an array and using stream-exhaust to ensure all data is read.

const exhaust = require('stream-exhaust');
const { Readable } = require('stream');

const readable = Readable.from(['data1', 'data2', 'data3']);

exhaust(readable).on('end', () => {
  console.log('Stream fully consumed');
});

Exhausting a Writable Stream

This feature ensures that a writable stream is fully consumed. The example demonstrates creating a writable stream and using stream-exhaust to ensure all data is written.

const exhaust = require('stream-exhaust');
const { Writable } = require('stream');

const writable = new Writable({
  write(chunk, encoding, callback) {
    console.log(chunk.toString());
    callback();
  }
});

exhaust(writable).on('finish', () => {
  console.log('Writable stream fully consumed');
});

writable.write('data1');
writable.write('data2');
writable.end('data3');

Exhausting a Duplex Stream

This feature ensures that a duplex stream is fully consumed. The example demonstrates creating a duplex stream and using stream-exhaust to ensure all data is read and written.

const exhaust = require('stream-exhaust');
const { Duplex } = require('stream');

const duplex = new Duplex({
  read(size) {
    this.push('data');
    this.push(null);
  },
  write(chunk, encoding, callback) {
    console.log(chunk.toString());
    callback();
  }
});

exhaust(duplex).on('end', () => {
  console.log('Duplex stream fully consumed');
});

Other packages similar to stream-exhaust

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc