ternary-stream
Advanced tools
Comparing version 1.0.1 to 1.1.0
25
index.js
'use strict'; | ||
var duplexer = require('duplexer'); | ||
var through2 = require('through2'); | ||
var ForkStream = require('fork-stream'); | ||
var eventStream = require('event-stream'); | ||
var duplexer2 = require('duplexer2'); | ||
@@ -25,18 +26,24 @@ module.exports = function (condition, trueStream, falseStream) { | ||
forkStream.a.pipe(trueStream); | ||
// then send down-stream | ||
trueStream.pipe(outStream); | ||
var mergedStream; | ||
if (falseStream) { | ||
// if there's an 'else' condition | ||
// if condition is false, pipe input to falseStream | ||
// if condition is false | ||
// pipe input to falseStream | ||
forkStream.b.pipe(falseStream); | ||
// then send down-stream | ||
falseStream.pipe(outStream); | ||
// merge output with trueStream's output | ||
mergedStream = eventStream.merge(falseStream, trueStream); | ||
} else { | ||
// if there's no 'else' condition | ||
// if condition is false, pipe down-stream | ||
forkStream.b.pipe(outStream); | ||
// if condition is false | ||
// merge output with trueStream's output | ||
mergedStream = eventStream.merge(forkStream.b, trueStream); | ||
} | ||
return duplexer(forkStream, outStream); | ||
// send everything down-stream | ||
mergedStream.pipe(outStream); | ||
// consumers write in to forkStream, we write out to outStream | ||
return duplexer2(forkStream, outStream); | ||
}; |
{ | ||
"name": "ternary-stream", | ||
"description": "Fork stream based on passed condition, and collect down-stream", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/robrich/ternary-stream", | ||
@@ -16,3 +16,4 @@ "repository": "git://github.com/robrich/ternary-stream.git", | ||
"dependencies": { | ||
"duplexer": "^0.1.1", | ||
"duplexer2": "^0.0.2", | ||
"event-stream": "^3.1.2", | ||
"fork-stream": "^0.0.4", | ||
@@ -19,0 +20,0 @@ "through2": "^0.4.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27997
39
4
+ Addedduplexer2@^0.0.2
+ Addedevent-stream@^3.1.2
+ Addedduplexer2@0.0.2(transitive)
+ Addedevent-stream@3.3.5(transitive)
+ Addedfrom@0.1.7(transitive)
+ Addedmap-stream@0.0.7(transitive)
+ Addedpause-stream@0.0.11(transitive)
+ Addedreadable-stream@1.1.14(transitive)
+ Addedsplit@1.0.1(transitive)
+ Addedstream-combiner@0.2.2(transitive)
+ Addedthrough@2.3.8(transitive)
- Removedduplexer@^0.1.1