1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +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,18 +58,13 @@ 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) {
while (length > 0x7f) {
lengthBytes.push((1 << 7) + (length & 0x7f))
length >>= 7
}
else {
lengthBytes.push(length)
more = false
}
}
this.push(new Buffer(lengthBytes))
this.push(chunk)