Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ternary-stream

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ternary-stream - npm Package Compare versions

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"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc