mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Simplify DelimitedStream a little.
This commit is contained in:
parent
34ff1efb43
commit
437596e6c6
1 changed files with 2 additions and 4 deletions
|
@ -17,20 +17,18 @@ DelimitedStream.prototype._transform = function(chunk, encoding, done) {
|
|||
while (this._buffer.length) {
|
||||
if (this._readingLength) {
|
||||
var byte = this._buffer[0]
|
||||
if (byte & (1 << 7)) {
|
||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
||||
if (byte & (1 << 7)) {
|
||||
this._lengthIndex += 1
|
||||
this._readingLength = true
|
||||
}
|
||||
else {
|
||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
||||
this._lengthIndex = 0
|
||||
this._readingLength = false
|
||||
}
|
||||
this._buffer = this._buffer.slice(1)
|
||||
}
|
||||
|
||||
if (!this._readingLength) {
|
||||
else {
|
||||
if (this._length <= this._buffer.length) {
|
||||
this.push(this._buffer.slice(0, this._length))
|
||||
this._buffer = this._buffer.slice(this._length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue