Comparing version
@@ -24,3 +24,3 @@ //another idea: buffer 2* the max, but only call write with half of that, | ||
writing = false | ||
console.log(ended, length, writing) | ||
if(ended === true && !length) cb(err) | ||
@@ -39,3 +39,3 @@ else if(ended && ended !== true) cb(err || ended) | ||
length = (queue && queue.length) || 0 | ||
flush() | ||
if(queue != null) flush() | ||
if(length < max) read(null, next) | ||
@@ -50,5 +50,1 @@ } | ||
{ | ||
"name": "pull-write", | ||
"description": "", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/dominictarr/pull-write", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -117,5 +117,24 @@ var tape = require('tape') | ||
tape('sometimes reduce to null', function (t) { | ||
var output = [] | ||
pull( | ||
pull.count(30), | ||
createWrite(function write(data, cb) { | ||
if(data == null) throw new Error('data cannot be null') | ||
setImmediate(function () { | ||
output = output.concat(data); cb() | ||
}) | ||
}, function (a, b) { | ||
if(!(b%2)) return a | ||
return (a||[]).concat(b) | ||
}, 10, function (err) { | ||
t.notOk(err) | ||
t.deepEqual(output, [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29 ]) | ||
t.end() | ||
}) | ||
) | ||
}) | ||
7841
6.77%162
12.5%