mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +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) {
|
while (this._buffer.length) {
|
||||||
if (this._readingLength) {
|
if (this._readingLength) {
|
||||||
var byte = this._buffer[0]
|
var byte = this._buffer[0]
|
||||||
|
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
||||||
if (byte & (1 << 7)) {
|
if (byte & (1 << 7)) {
|
||||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
|
||||||
this._lengthIndex += 1
|
this._lengthIndex += 1
|
||||||
this._readingLength = true
|
this._readingLength = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._length += (byte & 0x7f) << (7 * this._lengthIndex)
|
|
||||||
this._lengthIndex = 0
|
this._lengthIndex = 0
|
||||||
this._readingLength = false
|
this._readingLength = false
|
||||||
}
|
}
|
||||||
this._buffer = this._buffer.slice(1)
|
this._buffer = this._buffer.slice(1)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (!this._readingLength) {
|
|
||||||
if (this._length <= this._buffer.length) {
|
if (this._length <= this._buffer.length) {
|
||||||
this.push(this._buffer.slice(0, this._length))
|
this.push(this._buffer.slice(0, this._length))
|
||||||
this._buffer = this._buffer.slice(this._length)
|
this._buffer = this._buffer.slice(this._length)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue