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

multistream

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multistream

A stream that emits multiple other streams one after another (streams3)

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is multistream?

The 'multistream' npm package allows you to combine multiple streams into a single stream. This can be useful for tasks such as concatenating files, streaming data from multiple sources, or handling multiple input streams in a unified manner.

What are multistream's main functionalities?

Combining Multiple Streams

This feature allows you to combine multiple file streams into a single output stream. In this example, the contents of 'file1.txt', 'file2.txt', and 'file3.txt' are concatenated and written to 'combined.txt'.

const MultiStream = require('multistream');
const fs = require('fs');

const streams = [
  fs.createReadStream('file1.txt'),
  fs.createReadStream('file2.txt'),
  fs.createReadStream('file3.txt')
];

MultiStream(streams).pipe(fs.createWriteStream('combined.txt'));

Dynamic Stream Creation

This feature allows you to dynamically create streams based on a factory function. The factory function is called with an index and a callback, and it should call the callback with a new stream or null to indicate the end. In this example, streams for 'file1.txt', 'file2.txt', and 'file3.txt' are created dynamically and concatenated into 'combined.txt'.

const MultiStream = require('multistream');
const fs = require('fs');

const streamFactory = (i, callback) => {
  if (i > 3) return callback(null, null);
  callback(null, fs.createReadStream(`file${i}.txt`));
};

MultiStream(streamFactory).pipe(fs.createWriteStream('combined.txt'));

Other packages similar to multistream

Keywords

FAQs

Package last updated on 04 Feb 2021

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