    import BinaryEncoder from 'yjs/src/Util/Binary/Encoder.js'

public class | source

# BinaryEncoder

A BinaryEncoder handles the encoding to an ArrayBuffer.

## Constructor Summary

Public Constructor
public | constructor () |

## Member Summary

Public Members
public | data : *[] |
public get | length : * The current length of the encoded data. |
public get | pos : * The current write pointer (the same as length). |

## Method Summary

Public Methods
public | createBuffer (): Uint8Array Create an ArrayBuffer. |
public | setUint16 (pos: number, num: number) Write two bytes as an unsigned integer at a specific location. |
public | setUint32 (pos: number, num: number) Write two bytes as an unsigned integer at a specific location. |
public | setUint8 (pos: number, num: number) Write one byte as an unsigned Integer at a specific location. |
public | writeID (id: ID) Write an ID at the current position. |
public | writeUint16 (num: number) Write two bytes as an unsigned integer. |
public | writeUint32 (num: number) Write two bytes as an unsigned integer |
public | writeUint8 (num: number) Write one byte as an unsigned integer. |
public | writeVarString (str: String) Write a variable length string. |
public | writeVarUint (num: number) Write a variable length unsigned integer. |

## Public Constructors

### public constructor() source

## Public Members

### public data: *[] source

### public get length: * source

The current length of the encoded data.

### public get pos: * source

The current write pointer (the same as length).

## Public Methods

### public createBuffer(): Uint8Array source

Create an ArrayBuffer.

#### Return:

Uint8Array | A Uint8Array that represents the written data.

### public setUint16(pos: number, num: number) source

Write two bytes as an unsigned integer at a specific location.

#### Params:

Name | Type | Attribute | Description
pos | number |  | The location where the data will be written.
num | number |  | The number that is to be encoded.

### public setUint32(pos: number, num: number) source

Write two bytes as an unsigned integer at a specific location.

#### Params:

Name | Type | Attribute | Description
pos | number |  | The location where the data will be written.
num | number |  | The number that is to be encoded.

### public setUint8(pos: number, num: number) source

Write one byte as an unsigned Integer at a specific location.

#### Params:

Name | Type | Attribute | Description
pos | number |  | The location where the data will be written.
num | number |  | The number that is to be encoded.

### public writeID(id: ID) source

Write an ID at the current position.

#### Params:

Name | Type | Attribute | Description
id | ID |  | The ID that is to be written.

### public writeUint16(num: number) source

Write two bytes as an unsigned integer.

#### Params:

Name | Type | Attribute | Description
num | number |  | The number that is to be encoded.

### public writeUint32(num: number) source

Write two bytes as an unsigned integer

#### Params:

Name | Type | Attribute | Description
num | number |  | The number that is to be encoded.

### public writeUint8(num: number) source

Write one byte as an unsigned integer.

#### Params:

Name | Type | Attribute | Description
num | number |  | The number that is to be encoded.

### public writeVarString(str: String) source

Write a variable length string.

#### Params:

Name | Type | Attribute | Description
str | String |  | The string that is to be encoded.

### public writeVarUint(num: number) source

Write a variable length unsigned integer.

#### Params:

Name | Type | Attribute | Description
num | number |  | The number that is to be encoded.