Comparing version 4.0.1 to 5.0.0
15
index.js
@@ -19,4 +19,5 @@ var protobuf = require('protocol-buffers') | ||
var dup = duplexify.obj(decode, encode) | ||
var lazy = opts.lazy | ||
var addChannel = function(list, index, name) { | ||
var addChannel = function(list, index, name, open) { | ||
var stream = duplexify.obj() | ||
@@ -62,2 +63,7 @@ var channel = list === remote ? -(index+1) : index+1 | ||
if (open) { | ||
encode.write(messages.Frame.encode({channel:channel, type:TYPE.OPEN, name:name})) | ||
name = null | ||
} | ||
return stream | ||
@@ -83,3 +89,3 @@ } | ||
if (!reply && !remote[index] && onstream) { | ||
onstream(addChannel(remote, index, frame.name), frame.name || index) | ||
onstream(addChannel(remote, index, frame.name, false), frame.name || index) | ||
} | ||
@@ -93,2 +99,5 @@ | ||
switch (frame.type) { | ||
case TYPE.OPEN: | ||
return cb() | ||
case TYPE.DATA: | ||
@@ -129,3 +138,3 @@ return stream.write(frame.data, cb) | ||
if (index === -1) index = local.push(null)-1 | ||
return addChannel(local, index, name && ''+name) | ||
return addChannel(local, index, name && ''+name, !lazy) | ||
} | ||
@@ -132,0 +141,0 @@ |
{ | ||
"name": "multiplex", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "A binary stream multiplexer. Stream multiple streams of binary data over a single binary stream.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,6 +18,7 @@ # multiplex | ||
* `opts.error` - forward errors on individual streams | ||
* `opts.lazy` - only open a channel when you start writing to it | ||
### `multiplex.createStream([id])` | ||
Creates a new sub-stream with an optional whole string `id` (default is the stream channel id). | ||
Creates a new sub-stream with an optional whole string `id` (default is the stream channel id). | ||
@@ -24,0 +25,0 @@ Sub-streams are duplex streams. |
Sorry, the diff of this file is not supported yet
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
14810
312
72