summaryrefslogtreecommitdiff
path: root/lib/zlib.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zlib.js')
-rw-r--r--lib/zlib.js20
1 files changed, 1 insertions, 19 deletions
diff --git a/lib/zlib.js b/lib/zlib.js
index 9b453ea18..a8a79d2a6 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -150,25 +150,7 @@ function zlibBuffer(engine, buffer, callback) {
}
function onEnd() {
- var buffer;
- switch (buffers.length) {
- case 0:
- buffer = new Buffer(0);
- break;
- case 1:
- buffer = buffers[0];
- break;
- default:
- buffer = new Buffer(nread);
- var n = 0;
- buffers.forEach(function(b) {
- var l = b.length;
- b.copy(buffer, n, 0, l);
- n += l;
- });
- break;
- }
- callback(null, buffer);
+ callback(null, Buffer.concat(buffers, nread));
}
engine.on('error', onError);