Merge (interleave) a bunch of streams.

\href{http://travis-ci.org/grncdr/merge-stream}{\texttt{ }}\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17124}{}\doxysection{Synopsis}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17124}

\begin{DoxyCode}{0}
\DoxyCodeLine{var stream1 = new Stream();}
\DoxyCodeLine{var stream2 = new Stream();}
\DoxyCodeLine{}
\DoxyCodeLine{var merged = mergeStream(stream1, stream2);}
\DoxyCodeLine{}
\DoxyCodeLine{var stream3 = new Stream();}
\DoxyCodeLine{merged.add(stream3);}
\DoxyCodeLine{merged.isEmpty();}
\DoxyCodeLine{//=> false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17125}{}\doxysection{Description}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17125}
This is adapted from \href{https://github.com/dominictarr/event-stream}{\texttt{ event-\/stream}} separated into a new module, using Streams3.\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17126}{}\doxysection{API}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17126}
\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17127}{}\doxysubsection{$<$tt$>$merge\+Stream$<$/tt$>$}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17127}
Type\+: {\ttfamily function}

Merges an arbitrary number of streams. Returns a merged stream.\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17128}{}\doxysubsubsection{$<$tt$>$merged.\+add$<$/tt$>$}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17128}
A method to dynamically add more sources to the stream. The argument supplied to {\ttfamily add} can be either a source or an array of sources.\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17129}{}\doxysubsubsection{$<$tt$>$merged.\+is\+Empty$<$/tt$>$}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17129}
A method that tells you if the merged stream is empty.

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

So, we could do something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{stream = require('merge-\/stream')();}
\DoxyCodeLine{// Something like a loop to add some streams to the merge stream}
\DoxyCodeLine{// stream.add(streamA);}
\DoxyCodeLine{// stream.add(streamB);}
\DoxyCodeLine{return stream.isEmpty() ? null : stream; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17130}{}\doxysection{Gulp example}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17130}
An example use case for {\bfseries{merge-\/stream}} is to combine parts of a task in a project\textquotesingle{}s {\bfseries{gulpfile.\+js}} like this\+:


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

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_merge_stream_README_autotoc_md17131}{}\doxysection{License}\label{md_sfcode_node_modules_merge_stream_README_autotoc_md17131}
MIT 