Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
zlib: use Buffer.concat()
  • Loading branch information
isaacs committed Jun 15, 2012
1 parent 8ccb3cb commit a111390
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions lib/zlib.js
Expand Up @@ -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);
Expand Down

0 comments on commit a111390

Please sign in to comment.