Comparing version 3.4.3 to 3.4.4
15
index.js
@@ -27,2 +27,15 @@ var stream = require('readable-stream') | ||
var getStateLength = function(state) { | ||
if (state.buffer.length) { | ||
// Since node 6.3.0 state.buffer is a BufferList not an array | ||
if (state.buffer.head) { | ||
return state.buffer.head.data.length | ||
} | ||
return state.buffer[0].length | ||
} | ||
return state.length | ||
} | ||
var toStreams2 = function(rs) { | ||
@@ -162,3 +175,3 @@ return new (stream.Readable)({objectMode:true, highWaterMark:16}).wrap(rs) | ||
while ((data = this._readable2.read(state.buffer.length ? state.buffer[0].length : state.length)) !== null) { | ||
while ((data = this._readable2.read(getStateLength(state))) !== null) { | ||
this._drained = this.push(data) | ||
@@ -165,0 +178,0 @@ } |
{ | ||
"name": "duplexify", | ||
"version": "3.4.3", | ||
"version": "3.4.4", | ||
"description": "Turn a writeable and readable stream into a streams2 duplex stream with support for async initialization and streams1/streams2 input", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
25
test.js
var tape = require('tape') | ||
var through = require('through2') | ||
var concat = require('concat-stream') | ||
var net = require('net') | ||
var duplexify = require('./') | ||
@@ -269,2 +270,24 @@ | ||
}) | ||
}) | ||
}) | ||
tape('works with node native streams (net)', function(t) { | ||
t.plan(1) | ||
var server = net.createServer(function(socket) { | ||
var dup = duplexify(socket, socket) | ||
dup.once('data', function(chunk) { | ||
t.same(chunk, Buffer('hello world')) | ||
server.close() | ||
socket.end() | ||
t.end() | ||
}) | ||
}) | ||
server.listen(0, function () { | ||
var socket = net.connect(server.address().port) | ||
var dup = duplexify(socket, socket) | ||
dup.write(Buffer('hello world')) | ||
}) | ||
}) |
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
Network access
Supply chain riskThis module accesses the network.
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
17063
440
2