Create a new PBF instance and either read or write to it.
Follows the early Protobuf spec supporting various types of encoding
including messages (which are usually representative of class objects).
Destroys the PBF instance. You can still use the Pbf instance after calling
this method. However, the buffer will be emptied.
Returns void
readBoolean
readBoolean(): boolean
Returns boolean
parses the varint byte as a boolean expression
readBytes
readBytes(): Uint8Array
NOTE: bytes is preceeded by a varint dscribing the length of the bytes.
The bytes themselves are presumed to be u8s and therefore don't need to be decoded
Returns Uint8Array
the decoded byte array
readDouble
readDouble(): number
Read in a 64-bit float from the buffer. There are no compression advantages
with this type of encoding.
If you know you are reading a message, but have already read the length of
the message OR you're reading fields of the top level data, then this method
is the alternative. It's often used by sub-classes So that it can be
instationated prior to reading the message.
Reads a message from the buffer. Sometimes it's easier to manage sub structures
so that the current method can build multiples of an entire structure/class.
If you you are at the top level, or parsing the message inside a class, then
Write a message to the buffer. Allows you to pass in an object
with a write function to define how the message should be written.
A good tool to abstract away storing classes or sub-classes.
Type Parameters
T
Parameters
tag: number
the tag to write to associate with the message. This will help track how to
read following data.
Write a message to the buffer. Allows you to pass in an object
with a write function to define how the message should be written.
A good tool to abstract away storing classes or sub-classes.
Create a new PBF instance and either read or write to it. Follows the early Protobuf spec supporting various types of encoding including messages (which are usually representative of class objects).
Reading:
Writing: