mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Simplify DelimitingStream.
This commit is contained in:
parent
2291361eaa
commit
34ff1efb43
1 changed files with 5 additions and 10 deletions
|
@ -58,19 +58,14 @@ util.inherits(DelimitingStream, stream.Transform)
|
|||
DelimitingStream.prototype._transform = function(chunk, encoding, done) {
|
||||
var length = chunk.length
|
||||
var lengthBytes = []
|
||||
var more = true
|
||||
|
||||
while (more) {
|
||||
if (length > 0x7f) {
|
||||
lengthBytes.push((1 << 7) + (length & 0x7f))
|
||||
length >>= 7
|
||||
}
|
||||
else {
|
||||
lengthBytes.push(length)
|
||||
more = false
|
||||
}
|
||||
while (length > 0x7f) {
|
||||
lengthBytes.push((1 << 7) + (length & 0x7f))
|
||||
length >>= 7
|
||||
}
|
||||
|
||||
lengthBytes.push(length)
|
||||
|
||||
this.push(new Buffer(lengthBytes))
|
||||
this.push(chunk)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue