Create a new ISOBuffer.
Optionaldata: ISOBufferInput = DEFAULT_SIZEInitial data or size. Defaults to 8KB.
Optionaloptions: ISOBufferOptions = {}Configuration options
import { ISOBuffer } from 'iso-base/buffer'
// From size
const buf1 = new ISOBuffer(256)
// From Uint8Array (zero-copy)
const arr = new Uint8Array([1, 2, 3, 4])
const buf2 = new ISOBuffer(arr)
// From ArrayBuffer with offset
const ab = new ArrayBuffer(100)
const buf3 = new ISOBuffer(ab, { offset: 10 })
// Big-endian mode
const buf4 = new ISOBuffer(64, { littleEndian: false })
The underlying ArrayBuffer
Byte offset within the underlying ArrayBuffer
Uint8Array view over the buffer
Byte length of the buffer
Current cursor position
Byte length of the buffer (alias for length, for compatibility)
Check if there's enough space to read/write n bytes from current offset.
OptionalbyteLength: number = 1Number of bytes needed
True if space is available
Create a new ISOBuffer wrapping the same underlying buffer. Changes to either buffer affect the other.
Create a deep copy with its own ArrayBuffer.
Ensure buffer has enough space, growing if necessary. Growth strategy: double the required size.
OptionalbyteLength: number = 1Number of bytes needed
Get number of bytes written so far.
Check if big-endian mode is active.
Check if little-endian mode is active.
Read signed 64-bit BigInt, advance cursor by 8.
Read unsigned 64-bit BigInt, advance cursor by 8.
Read a boolean (1 byte, false if 0, true otherwise).
Read n bytes as Uint8Array (zero-copy subarray), advance cursor.
Number of bytes to read
Read 32-bit float, advance cursor by 4.
Read 64-bit double, advance cursor by 8.
Read signed 16-bit integer, advance cursor by 2.
Read signed 32-bit integer, advance cursor by 4.
Read signed 8-bit integer, advance cursor by 1.
Read unsigned LEB128 encoded bigint, advance cursor.
The decoded value
Read unsigned 16-bit integer, advance cursor by 2.
Read unsigned 32-bit integer, advance cursor by 4.
Read unsigned 8-bit integer, advance cursor by 1.
Read n bytes and decode as UTF-8 string.
Number of bytes to read
Get remaining bytes available from current offset.
Move cursor back to start (offset 0).
Switch to big-endian mode.
Switch to little-endian mode.
Get a zero-copy subarray view.
Optionalstart: number = 0Start offset
Optionalend: numberEnd offset (defaults to length)
Get a Uint8Array of the written portion of the buffer. This is a view from byteOffset to lastWrittenByte.
Write boolean as single byte (0xff for true, 0x00 for false).
Write bytes from Uint8Array, advance cursor.
Write unsigned LEB128 encoded bigint.
Value to encode
Write unsigned varint (multiformats style), advance cursor.
Value to encode (must be non-negative safe integer)
Cross-platform binary buffer with auto-advancing cursor.
Example