How to use the BufferReader function from protobufjs

Find comprehensive JavaScript protobufjs.BufferReader code examples handpicked from public code repositorys.

30
31
32
33
34
35
36
37
38
39
         *
         * @param {Buffer} firstChunk - first chunk (or whole) of serialized data
         * @return {{length: number, dataOffset: number}} length - data length, dataOffset - position of payload in chunk
         */
        static readMsgLength(firstChunk) {
            const buffReader = new BufferReader(firstChunk);
            return {length: buffReader.int32(), dataOffset: buffReader.pos};
        }
    };
};
fork icon20
star icon16
watch icon8

+ 5 other calls in file

154
155
156
157
158
159
160
161
162
163
  this._onGotMessageSize();
}

_onGotMessageSize() {
  let incompleteSizePacket = false;
  const reader = new BufferReader(this._data);

  try {
    this._messageSize = reader.int32();
  } catch (error) {
fork icon61
star icon0
watch icon10

+ 3 other calls in file

167
168
169
170
171
172
173
174
175
176
}

// TODO(ibash) in chromium code there is an extra check here of:
// if prev_byte_count >= kSizePacketLenMax then something else went wrong
// NOTE(ibash) I could only test this case by manually cutting the buffer
// above to be mid-packet like: new BufferReader(this._data.slice(0, 1))
if (incompleteSizePacket) {
  this._sizePacketSoFar = reader.pos;
  this._state = MCS_SIZE;
  this._waitForData();
fork icon61
star icon0
watch icon0

+ 3 other calls in file

160
161
162
163
164
165
166
167
168
169
 * @method formatOutputBool
 * @param {Buffer} bytes
 * @returns {Boolean}
 */
var formatOutputBool = function (bytes) {
    var r = new protobuf.BufferReader(bytes);
    // Tag
    r.uint32();
    return r.bool();
};
fork icon1
star icon0
watch icon2

+ 11 other calls in file