The type of values this object can serialize
The type of values this object deserializes.
Must be a subset of VALUE
. Defaults to VALUE
.
Appends the type information to an AppendableBuffer
The buffer to append to
false
if it wrote a pointer to a previous instance, true
if it wrote the type byte. For internal use.
Reads a value from the specified bytes at the specified offset. Returns the value that was read and the number of bytes consumed.
The buffer containing the value bytes
The position in the buffer to read from
A value to mutate into the read value. Used by RecursiveType.
The read value and the number of bytes read
Returns whether this type object represents the same type as another object
Another object to compare with
true
iff the types would be serialized to the same bytes
Gets a base-64 SHA256 hash of the type, using a cached value if present
A hash of the buffer given by toBuffer
Gets a signature string for the type, using a cached value if present. This string encodes the specification version and the type hash. Represented as a base-64 string.
A signature for the type
Deserializes a value, i.e. takes
a buffer containing its binary form
and returns the value.
The inverse of valueBuffer.
Requires the type (this
) to be known.
Example:
let type = new sb.ArrayType(
new sb.FlexUnsignedIntType
)
let value = [0, 10, 100, 1000, 10000]
let buffer = type.valueBuffer(value)
let readValue = type.readValue(buffer)
console.log(readValue) // [ 0, 10, 100, 1000, 10000 ]
The buffer containing the value bytes
The position in the buffer to read from
(defaults to 0
)
A value equivalent to the one that was written
Gets the type in buffer form, using a cached value if present. Since types are immutable, the result should never change from the cached value.
A buffer containing the type bytes
Gets an ArrayBuffer
containing the value in binary format.
See this type's writeValue documentation for examples of values.
The value to write
An ArrayBuffer
storing the value
Appends value bytes to an AppendableBuffer according to the type
The buffer to which to append
The value to write
Generated using TypeDoc
An interface representing an object that can serialize values of a certain type. The object must also be able to serialize itself.