Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

merge-stream

Package Overview
Dependencies
0
Maintainers
3
Versions
13
Issues
File Explorer

Advanced tools

merge-stream

Create a stream that emits events from multiple other streams

    2.0.0latest

Version published
Maintainers
3
Weekly downloads
25,033,421
decreased by-10.83%

Weekly downloads

Readme

Source

merge-stream

Merge (interleave) a bunch of streams.

build status

Synopsis

var stream1 = new Stream(); var stream2 = new Stream(); var merged = mergeStream(stream1, stream2); var stream3 = new Stream(); merged.add(stream3); merged.isEmpty(); //=> false

Description

This is adapted from event-stream separated into a new module, using Streams3.

API

mergeStream

Type: function

Merges an arbitrary number of streams. Returns a merged stream.

merged.add

A method to dynamically add more sources to the stream. The argument supplied to add can be either a source or an array of sources.

merged.isEmpty

A method that tells you if the merged stream is empty.

When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task.

So, we could do something like this:

stream = require('merge-stream')(); // Something like a loop to add some streams to the merge stream // stream.add(streamA); // stream.add(streamB); return stream.isEmpty() ? null : stream;

Gulp example

An example use case for merge-stream is to combine parts of a task in a project's gulpfile.js like this:

const gulp = require('gulp'); const htmlValidator = require('gulp-w3c-html-validator'); const jsHint = require('gulp-jshint'); const mergeStream = require('merge-stream'); function lint() { return mergeStream( gulp.src('src/*.html') .pipe(htmlValidator()) .pipe(htmlValidator.reporter()), gulp.src('src/*.js') .pipe(jsHint()) .pipe(jsHint.reporter()) ); } gulp.task('lint', lint);

License

MIT

FAQs

What is merge-stream?

Create a stream that emits events from multiple other streams

Is merge-stream popular?

The npm package merge-stream receives a total of 20,179,011 weekly downloads. As such, merge-stream popularity was classified as popular.

Is merge-stream well maintained?

We found that merge-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 3 open source maintainers collaborating on the project.

Last updated on 23 May 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc