var bufSize = (unreadedSize * 2 > this.defaultReadBufferSize) ? unreadedSize * 2 : this.defaultReadBufferSize;
var buf = new Buffer(bufSize);
if (unreadedSize > 0) {
- this.inBuf.copy(buf, 0, this.readCursor, unreadedSize);
+ this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor);
}
this.readCursor = 0;
this.writeCursor = unreadedSize;
throw new InputBufferUnderrunError();
}
var buf = new Buffer(this.writeCursor - this.readCursor);
- this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor - this.readCursor);
+ this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor);
this.readCursor = this.writeCursor;
return buf;
},