tree-stream
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -18,2 +18,3 @@ import { Duplex, Readable, Writable } from 'stream' | ||
pipe(stream: Duplex): ReadableStreamTree | ||
piped(parent: ReadableStreamTree): void | ||
split(children?: number): ReadableStreamTree[] | ||
@@ -28,2 +29,3 @@ } | ||
pipeFrom(stream: Duplex): WritableStreamTree | ||
pipedFrom(parent: WritableStreamTree): void | ||
} | ||
@@ -30,0 +32,0 @@ |
35
index.js
@@ -75,3 +75,6 @@ var once = require('once') | ||
propagateDestroyForward(node, node.error) | ||
if (node.callback) node.callback(node.error) | ||
if (node.callback) { | ||
node.callback(node.error) | ||
node.callback = null | ||
} | ||
}) | ||
@@ -94,2 +97,6 @@ } | ||
node.destroy() | ||
if (node.callback) { | ||
node.callback(node.error) | ||
node.callback = null | ||
} | ||
if (node.parentNode) { | ||
@@ -113,4 +120,4 @@ var parentChildren = node.parentNode.childNode.length | ||
var pipe = function(parentNode, stream) { | ||
var childNode = createNode(stream, parentNode) | ||
addDestroyer(parentNode, true, parentNode.stream != rootStream) | ||
var childNode = createNode(stream) | ||
piped(parentNode, childNode) | ||
parentNode.stream.pipe(stream) | ||
@@ -120,2 +127,8 @@ return createHandle(childNode) | ||
var piped = function(parentNode, childNode) { | ||
parentNode.childNode.push(childNode) | ||
childNode.parentNode = parentNode | ||
addDestroyer(parentNode, true, parentNode.stream != rootStream) | ||
} | ||
// With this utility you can pipe readable stream into multiple writable streams. | ||
@@ -146,2 +159,3 @@ var split = function(parentNode, children) { | ||
handle.pipe = function(stream) { return pipe(node, stream) } | ||
handle.piped = function(childNode) { return piped(node, childNode.node) } | ||
handle.split = function(children=2) { return split(node, children) } | ||
@@ -160,6 +174,3 @@ return handle | ||
var parentNode = createNode(stream) | ||
parentNode.childNode.push(childNode) | ||
childNode.parentNode = parentNode | ||
addDestroyer(childNode, childNode.stream != terminalStream, true) | ||
pipedFrom(childNode, parentNode) | ||
stream.pipe(childNode.stream) | ||
@@ -169,2 +180,9 @@ return createHandle(parentNode) | ||
var pipedFrom = function(childNode, parentNode, external) { | ||
if (!parentNode.destroyed) parentNode.destroyed = new Set() | ||
parentNode.childNode.push(childNode) | ||
childNode.parentNode = parentNode | ||
addDestroyer(childNode, external || childNode.stream != terminalStream, true) | ||
} | ||
// Analogous to readableStreamTree.split, returns Readables. | ||
@@ -217,3 +235,3 @@ var joinReadable = function(siblingNode, siblings, newPassThrough) { | ||
addDestroyer(finalNode, finalNode.stream != terminalStream, true) | ||
addDestroyer(finalNode, finalNode.destroyed || finalNode.stream != terminalStream, true) | ||
if (readNode) { | ||
@@ -235,2 +253,3 @@ addDestroyer(readNode, true, false) | ||
handle.pipeFrom = function(stream) { return pipeFrom(node, stream) } | ||
handle.pipedFrom = function(parentNode) { return pipedFrom(node, parentNode.node, true) } | ||
return handle | ||
@@ -237,0 +256,0 @@ } |
{ | ||
"name": "tree-stream", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"repository": "git://github.com/wholenews/tree-stream", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
59804
10
408