Small refactor
This commit is contained in:
+10
-10
@@ -46,6 +46,14 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
|
|||||||
var buffer_offset = 0;
|
var buffer_offset = 0;
|
||||||
var buffer_sent = false;
|
var buffer_sent = false;
|
||||||
|
|
||||||
|
this.pushBufferIfneeded = function() {
|
||||||
|
if(needPush && !buffer_sent && buffer_offset > 0) {
|
||||||
|
this.push(buffer.slice(0, buffer_offset))
|
||||||
|
buffer_sent = true;
|
||||||
|
buffer_offset = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while((chunk.length - offset) >= (Byte1Len + Int32Len)) {
|
while((chunk.length - offset) >= (Byte1Len + Int32Len)) {
|
||||||
var messageCode = chunk[offset]
|
var messageCode = chunk[offset]
|
||||||
|
|
||||||
@@ -74,11 +82,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
|
|||||||
|
|
||||||
case code.ErrorResponse:
|
case code.ErrorResponse:
|
||||||
case code.CopyDone:
|
case code.CopyDone:
|
||||||
if(needPush && !buffer_sent && buffer_offset > 0) {
|
this.pushBufferIfneeded();
|
||||||
this.push(buffer.slice(0, buffer_offset))
|
|
||||||
buffer_sent = true;
|
|
||||||
buffer_offset = 0;
|
|
||||||
}
|
|
||||||
this._detach()
|
this._detach()
|
||||||
this.push(null)
|
this.push(null)
|
||||||
return cb();
|
return cb();
|
||||||
@@ -103,11 +107,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needPush && !buffer_sent && buffer_offset > 0) {
|
this.pushBufferIfneeded();
|
||||||
this.push(buffer.slice(0, buffer_offset))
|
|
||||||
buffer_sent = true;
|
|
||||||
buffer_offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chunk.length - offset) {
|
if(chunk.length - offset) {
|
||||||
var slice = chunk.slice(offset)
|
var slice = chunk.slice(offset)
|
||||||
|
|||||||
Reference in New Issue
Block a user