1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Simplify DelimitingStream.

This commit is contained in:
Simo Kinnunen 2014-07-28 08:45:33 +09:00
parent 2291361eaa
commit 34ff1efb43

View file

@ -58,19 +58,14 @@ util.inherits(DelimitingStream, stream.Transform)
DelimitingStream.prototype._transform = function(chunk, encoding, done) { DelimitingStream.prototype._transform = function(chunk, encoding, done) {
var length = chunk.length var length = chunk.length
var lengthBytes = [] var lengthBytes = []
var more = true
while (more) { while (length > 0x7f) {
if (length > 0x7f) { lengthBytes.push((1 << 7) + (length & 0x7f))
lengthBytes.push((1 << 7) + (length & 0x7f)) length >>= 7
length >>= 7
}
else {
lengthBytes.push(length)
more = false
}
} }
lengthBytes.push(length)
this.push(new Buffer(lengthBytes)) this.push(new Buffer(lengthBytes))
this.push(chunk) this.push(chunk)