Do not register the pushBufferIfNeeded method on the instance

This commit is contained in:
jeromew 2019-03-15 10:12:20 +00:00
parent 9c46a8223e
commit df47d58d74

View File

@ -47,9 +47,10 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
var buffer = Buffer.alloc(chunk.length);
var buffer_offset = 0;
this.pushBufferIfneeded = function() {
var self = this;
var pushBufferIfneeded = function() {
if (needPush && buffer_offset > 0) {
this.push(buffer.slice(0, buffer_offset))
self.push(buffer.slice(0, buffer_offset))
buffer_offset = 0;
}
}
@ -82,7 +83,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
case code.ErrorResponse:
case code.CopyDone:
this.pushBufferIfneeded();
pushBufferIfneeded();
this._detach()
this.push(null)
return cb();
@ -107,7 +108,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
}
}
this.pushBufferIfneeded();
pushBufferIfneeded();
if(chunk.length - offset) {
var slice = chunk.slice(offset)