API reference / @jsprismarine/script-host / values / TransferBuffer
Class: TransferBuffer
Defined in: script-host/src/values.ts:40
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
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
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
The buffer's size in bytes.
Returns
number
memory
Get Signature
get memory():
SharedArrayBuffer
Defined in: script-host/src/values.ts:56
The current shared memory.
Returns
SharedArrayBuffer
Methods
reserve()
reserve(
needed):void
Defined in: script-host/src/values.ts:74
Makes room for needed bytes, keeping what the buffer already holds.
Parameters
needed
number
The size the buffer must have, in bytes.
Returns
void