Socket
Socket
Sign inDemoInstall

stream-each

Package Overview
Dependencies
4
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stream-each

Iterate all the data in a stream


Version published
Weekly downloads
5.4M
increased by3.79%
Maintainers
3
Install size
27.4 kB
Created
Weekly downloads
 

Package description

What is stream-each?

The stream-each package is a utility that allows for iterating over the data in a readable stream one chunk at a time. It works by providing a function that is called for each chunk of data read from the stream, and a callback that is called when there is no more data or an error occurs.

What are stream-each's main functionalities?

Iterating over stream data

This feature allows you to process data from a stream chunk by chunk. The provided code sample demonstrates how to read from a file stream and log each chunk of data to the console.

const each = require('stream-each');
const fs = require('fs');

const stream = fs.createReadStream('/path/to/file.txt');
each(stream, function (chunk, next) {
  console.log(chunk.toString());
  next();
}, function (err) {
  if (err) throw err;
  console.log('Finished reading the stream.');
});

Other packages similar to stream-each

Readme

Source

stream-each

Iterate all the data in a stream

npm install stream-each

build status

Usage

var each = require('stream-each')

each(stream, function (data, next) {
  console.log('data from stream', data)
  // when ready to consume next chunk
  next()
}, function (err) {
  console.log('no more data')
})

API

each(stream, iterator, cb)

Iterate the data in the stream by calling the iterator function with (data, next) where data is a data chunk and next is a callback. Call next when you are ready to consume the next chunk. Optionally you can call next with an error to destroy the stream

When the stream ends/errors the callback is called if provided

License

MIT

stream-each is part of the mississippi stream utility collection which includes more useful stream modules similar to this one.

FAQs

Last updated on 30 Jul 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc