merge-stream

WebJar for merge-stream

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

merge-stream
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

merge-stream
WebJar for merge-stream
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/grncdr/merge-stream

Download merge-stream

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/merge-stream/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>merge-stream</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/merge-stream/
implementation 'org.webjars.npm:merge-stream:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/merge-stream/
implementation ("org.webjars.npm:merge-stream:2.0.0")
'org.webjars.npm:merge-stream:jar:2.0.0'
<dependency org="org.webjars.npm" name="merge-stream" rev="2.0.0">
  <artifact name="merge-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='merge-stream', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "merge-stream" % "2.0.0"
[org.webjars.npm/merge-stream "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
2.0.0
1.0.1
0.1.7