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

stream-array

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-array

Pipe an Array through Node.js streams

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is stream-array?

The stream-array npm package allows you to create a readable stream from an array of data. This can be useful for processing data in a stream-based manner, which is often more efficient and scalable than processing data in a batch.

What are stream-array's main functionalities?

Create a readable stream from an array

This feature allows you to convert an array into a readable stream. The code sample demonstrates how to create a readable stream from an array of numbers and log each chunk of data as it is read from the stream.

const streamArray = require('stream-array');
const array = [1, 2, 3, 4, 5];
const readableStream = streamArray(array);
readableStream.on('data', (chunk) => {
  console.log(chunk);
});

Pipe the stream to another writable stream

This feature allows you to pipe the readable stream created from an array to another writable stream. The code sample demonstrates how to create a readable stream from an array of strings and pipe it to a writable stream that logs each chunk of data.

const streamArray = require('stream-array');
const { Writable } = require('stream');
const array = ['a', 'b', 'c'];
const readableStream = streamArray(array);
const writableStream = new Writable({
  write(chunk, encoding, callback) {
    console.log(chunk.toString());
    callback();
  }
});
readableStream.pipe(writableStream);

Other packages similar to stream-array

Keywords

FAQs

Package last updated on 20 May 2013

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