diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-24 00:30:28 +0600 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-24 00:30:28 +0600 |
commit | 667aae596cded9336f50574386683ec39ada43f2 (patch) | |
tree | 41918ad8d4801cc34215b054cb63dc83bd1ce8a5 /lib/zlib.js | |
parent | 2433eeb3850a91feb99bab530cb7183800166390 (diff) | |
parent | 6c0c00a2052ec613503a0322dcbabb6fcf41dab0 (diff) | |
download | node-667aae596cded9336f50574386683ec39ada43f2.tar.gz |
Merge branch 'v0.6'
Conflicts:
ChangeLog
doc/template.html
lib/cluster.js
lib/http.js
lib/tls.js
src/node.h
src/node_version.h
test/simple/test-cluster-kill-workers.js
Diffstat (limited to 'lib/zlib.js')
-rw-r--r-- | lib/zlib.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/zlib.js b/lib/zlib.js index 339f1e713..349c5c64d 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -122,18 +122,18 @@ function zlibBuffer(engine, buffer, callback) { var buffers = []; var nread = 0; - engine.on('error', function(err) { - engine.removeListener('end'); - engine.removeListener('error'); + function onError(err) { + engine.removeListener('end', onEnd); + engine.removeListener('error', onError); callback(err); - }); + } - engine.on('data', function(chunk) { + function onData(chunk) { buffers.push(chunk); nread += chunk.length; - }); + } - engine.on('end', function() { + function onEnd() { var buffer; switch(buffers.length) { case 0: @@ -153,7 +153,11 @@ function zlibBuffer(engine, buffer, callback) { break; } callback(null, buffer); - }); + } + + engine.on('error', onError); + engine.on('data', onData); + engine.on('end', onEnd); engine.write(buffer); engine.end(); |