[Pkg-javascript-commits] [node-stream-combiner2] 14/41: Allow passing array of streams

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:57:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-stream-combiner2.

commit 513e9e0882336d341dfdcfccc5b5b690cbb735b6
Author: E.Azer Koçulu <azer at kodfabrik.com>
Date:   Sun May 18 00:27:17 2014 -0700

    Allow passing array of streams
---
 index.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/index.js b/index.js
index caff1bc..e23374c 100644
--- a/index.js
+++ b/index.js
@@ -2,7 +2,13 @@ var duplexer = require('duplexer')
 var through = require('through')
 
 module.exports = function () {
-  var streams = [].slice.call(arguments)
+  var streams
+
+  if(arguments.length == 1 && Array.isArray(arguments[0])) {
+    streams = arguments[0]
+  } else {
+    streams = [].slice.call(arguments)
+  }
 
   if(streams.length == 0)
     return through()
@@ -19,17 +25,17 @@ module.exports = function () {
     if(streams.length < 2)
       return
     streams[0].pipe(streams[1])
-    recurse(streams.slice(1))  
+    recurse(streams.slice(1))
   }
-  
+
   recurse(streams)
- 
+
   function onerror () {
     var args = [].slice.call(arguments)
     args.unshift('error')
     thepipe.emit.apply(thepipe, args)
   }
-  
+
   //es.duplex already reemits the error from the first and last stream.
   //add a listener for the inner streams in the pipeline.
   for(var i = 1; i < streams.length - 1; i ++)
@@ -37,4 +43,3 @@ module.exports = function () {
 
   return thepipe
 }
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-combiner2.git



More information about the Pkg-javascript-commits mailing list