File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,14 @@ export class Parser {
150
150
this . remainingBufferLength = 0
151
151
this . remainingBufferOffset = 0
152
152
} else {
153
+ this . remainingBufferLength = fullLength - offset
153
154
if ( reuseRemainingBuffer ) {
154
155
// Adjust the cursors of remainingBuffer
155
- this . remainingBufferLength = combinedBufferLength - offset
156
- this . remainingBufferOffset += offset
156
+ this . remainingBufferOffset = offset
157
157
} else {
158
- // To avoid side effects, copy the remaining part of the new buffer to remainingBuffer
159
- this . remainingBuffer = combinedBuffer . slice ( offset )
160
- this . remainingBufferLength = this . remainingBuffer . byteLength
158
+ // To avoid side effects, copy the remaining part of the new buffer to remainingBuffer with extra space for next buffer
159
+ this . remainingBuffer = Buffer . allocUnsafe ( combinedBufferLength * 2 )
160
+ combinedBuffer . copy ( this . remainingBuffer , 0 , offset )
161
161
this . remainingBufferOffset = 0
162
162
}
163
163
}
You can’t perform that action at this time.
0 commit comments