From f21bb949dcb626aa716c59de08d37f748e1d6599 Mon Sep 17 00:00:00 2001 From: Keith Beckman Date: Thu, 22 Aug 2013 22:57:45 -0400 Subject: [PATCH] Fix and test for Issue #41 --- lazy.js | 2 +- test/lines.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lazy.js b/lazy.js index 08a01e7..52bd4ce 100644 --- a/lazy.js +++ b/lazy.js @@ -333,7 +333,7 @@ var mergeBuffers = function mergeBuffers(buffers) { var finalBufferLength, finalBuffer, currentBuffer, currentSize = 0; // Sum all the buffers lengths - finalBufferLength = buffers.reduce(function(left, right) { return (left.length||left) + (right.length||right); }, 0); + finalBufferLength = buffers.reduce(function(left, right) { return left + right.length; }, 0); finalBuffer = new Buffer(finalBufferLength); while(buffers.length) { currentBuffer = buffers.shift(); diff --git a/test/lines.js b/test/lines.js index b33cc0e..4bc2286 100644 --- a/test/lines.js +++ b/test/lines.js @@ -87,3 +87,11 @@ exports.endStream = function () { em.emit('end'); }, 200); }; + +exports.blankLine = function () { + var data = 'abc\n\ndef\n'; + var l = Lazy(); + l.lines.join(function (x) { assert.eql(x.join('\n') + '\n', data); }); + l.emit('data', data); + l.emit('end'); +};