    import BinaryDecoder from 'yjs/src/Util/Binary/Decoder.js'

public class | source

# BinaryDecoder

A BinaryDecoder handles the decoding of an ArrayBuffer.

## Constructor Summary

Public Constructor
public | constructor (buffer: Uint8Array | Buffer) |

## Member Summary

Public Members
public get | length : * Number of bytes. |
public | pos : number |
public | uint8arr : * |

## Method Summary

Public Methods
public | clone (newPos: *): * Clone this decoder instance. |
public | peekUint8 (): number Look ahead without incrementing position. |
public | peekVarString (): * Look ahead and read varString without incrementing position |
public | readID (): * Read ID. |
public | readUint32 (): number Read 4 bytes as unsigned integer. |
public | readUint8 (): * Read one byte as unsigned integer. |

public

readVarString (): String

Read string of variable length

- varUint is used to store the length of the string

public | readVarUint (): number Read unsigned integer (32bit) with variable length. |
public | skip8 () Skip one byte, jump to the next position. |

## Public Constructors

### public constructor(buffer: Uint8Array | Buffer) source

#### Params:

Name | Type | Attribute | Description
buffer | Uint8Array | Buffer |  | The binary data that this instance decodes.

## Public Members

### public get length: * source

Number of bytes.

### public pos: number source

### public uint8arr: * source

## Public Methods

### public clone(newPos: *): * source

Clone this decoder instance. Optionally set a new position parameter.

#### Params:

Name | Type | Attribute | Description

newPos

*

- optional

#### Return:

*

### public peekUint8(): number source

Look ahead without incrementing position. to the next byte and read it as unsigned integer.

#### Return:

number | An unsigned integer.

### public peekVarString(): * source

Look ahead and read varString without incrementing position

#### Return:

*

### public readID(): * source

Read ID.

- If first varUint read is 0xFFFFFF a RootID is returned.
- Otherwise an ID is returned.

#### Return:

* | ID

### public readUint32(): number source

Read 4 bytes as unsigned integer.

#### Return:

number | An unsigned integer.

### public readUint8(): * source

Read one byte as unsigned integer.

#### Return:

*

### public readVarString(): String source

Read string of variable length

- varUint is used to store the length of the string

#### Return:

String | The read String.

### public readVarUint(): number source

Read unsigned integer (32bit) with variable length. 1/8th of the storage is used as encoding overhead.

- numbers < 2^7 is stored in one byte.
- numbers < 2^14 is stored in two bytes.

#### Return:

number | An unsigned integer.

### public skip8() source

Skip one byte, jump to the next position.