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

stream-consume

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-consume

Consume a stream to ensure it keeps flowing

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
238K
decreased by-34.54%
Maintainers
1
Weekly downloads
 
Created

What is stream-consume?

The 'stream-consume' npm package is used to ensure that a stream is completely consumed. This is particularly useful when working with streams that you need to fully read or process, as it helps to avoid memory leaks by ensuring that all data is read from the stream.

What are stream-consume's main functionalities?

Consume a Readable Stream

This feature allows you to consume a readable stream. The code sample demonstrates creating a readable stream and then consuming it using the 'stream-consume' package.

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

const readable = new Readable({
  read(size) {
    this.push('data');
    this.push(null); // No more data
  }
});

consume(readable);

Handle Stream Errors

This feature ensures that any errors emitted by the stream are handled. The code sample demonstrates creating a readable stream that emits an error and then consuming it using the 'stream-consume' package.

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

const readable = new Readable({
  read(size) {
    this.emit('error', new Error('Stream error'));
  }
});

consume(readable);

Other packages similar to stream-consume

FAQs

Package last updated on 15 Feb 2018

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