mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-27 19:25:13 +02:00
Simplify DelimitedStream a little.
This commit is contained in:
@@ -17,20 +17,18 @@ DelimitedStream.prototype._transform = function(chunk, encoding, done) {
|
||||
while (this._buffer.length) {
|
||||
if (this._readingLength) {
|
||||
var byte = this._buffer[0]
|
||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
||||
if (byte & (1 << 7)) {
|
||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user