[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / [values](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md) / TransferBuffer

# Class: TransferBuffer

Defined in: [script-host/src/values.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L40)

An engine's transfer buffer: shared memory whose address the engine holds. Growing it moves the
bytes written so far into a new buffer and hands that buffer to the engine.

## Constructors

### Constructor

> **new TransferBuffer**(`capacity`, `replaced`): `TransferBuffer`

Defined in: [script-host/src/values.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L49)

#### Parameters

##### capacity

`number`

The first buffer's size in bytes.

##### replaced

(`memory`) => `void`

Hands a new buffer to the engine. It runs after every growth.

#### Returns

`TransferBuffer`

## Accessors

### bytes

#### Get Signature

> **get** **bytes**(): `Buffer`

Defined in: [script-host/src/values.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L61)

A view of the current memory, which growth replaces.

##### Returns

`Buffer`

***

### capacity

#### Get Signature

> **get** **capacity**(): `number`

Defined in: [script-host/src/values.ts:66](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L66)

The buffer's size in bytes.

##### Returns

`number`

***

### memory

#### Get Signature

> **get** **memory**(): `SharedArrayBuffer`

Defined in: [script-host/src/values.ts:56](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L56)

The current shared memory.

##### Returns

`SharedArrayBuffer`

## Methods

### reserve()

> **reserve**(`needed`): `void`

Defined in: [script-host/src/values.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/values.ts#L74)

Makes room for `needed` bytes, keeping what the buffer already holds.

#### Parameters

##### needed

`number`

The size the buffer must have, in bytes.

#### Returns

`void`
