From 0bd6c4663f3bdfb75742239fcc36997f747aaa81 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 10 Feb 2016 15:48:28 +0000 Subject: [PATCH] Link internal buffers in append() This provides support for node v5.6.0. Fixes #26. --- bl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bl.js b/bl.js index b979ba8..661e072 100644 --- a/bl.js +++ b/bl.js @@ -57,8 +57,14 @@ BufferList.prototype.append = function (buf) { if (typeof buf == 'number') buf = buf.toString() - this._bufs.push(isBuffer ? buf : new Buffer(buf)) - this.length += buf.length + if (buf instanceof BufferList) { + this._bufs = this._bufs.concat(buf._bufs) + this.length += buf.length + } else { + this._bufs.push(isBuffer ? buf : new Buffer(buf)) + this.length += buf.length + } + return this }