Class: BinaryEncoder
A class that provides methods for encoding binary data.
Constructors
new BinaryEncoder()
new BinaryEncoder(
writer
:BufferWriter
):BinaryEncoder
Creates a new binary encoder.
Parameters
Parameter | Type | Description |
---|---|---|
| The buffer writer |
Returns
Defined in
Methods
create()
static
create(byteLength
:number
,options
:Partial
<ResizeOptions
>):BinaryEncoder
Creates a new binary encoder from a buffer writer.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The initial byte length of the buffer |
| BufferWriter options |
Returns
The new binary encoder instance
Throws
RangeError if the initial buffer size is invalid or the maxByteLength is less than the initial buffer size
Defined in
reset()
reset():
void
Resets the buffer writer.
Returns
void
Defined in
encode()
encode<
T
>(schema
:T
,value
:InferBaseType
<T
>):void
Encodes a value to the buffer.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type | Description |
---|---|---|
|
| The schema of the value to encode |
| The value to encode |
Returns
void
Throws
RangeError if the value is invalid or the value size is larger than the buffer maximum size
Defined in
commit()
commit():
ArrayBuffer
Commits the buffer as an ArrayBuffer.
Returns
The ArrayBuffer containing the encoded data
Defined in
commitUint8Array()
commitUint8Array():
Uint8Array
Commits the buffer as an Uint8Array.
Returns
The Uint8Array containing the encoded data
Defined in
toUint8Array()
toUint8Array():
Uint8Array
Converts the buffer to an Uint8Array.
Returns
The Uint8Array containing the encoded data
Defined in
Properties
Property | Modifier | Type | Description | Defined in |
---|---|---|---|---|
writer | readonly | BufferWriter | The buffer writer. | binary-encoder.ts:13 |