ByteCursor
Defined in: packages/format-core/src/byte-cursor.ts:19
Sequential reader over a possibly non-contiguous byte sequence.
All methods are relative to an internal cursor, reset to position 0 before
each decode attempt by whatever DecodeDriver owns the backing
ChunkListBuffer — a decoder still reports consumed, so the single
DecodeResult contract holds whether the backing is contiguous or not.
peek* inspects without advancing; read* advances. Absolute positions are
never exposed, so a decoder written against this interface is agnostic to the
backing layout.
Named ByteCursor, not ByteReader — @ac-kit/core already exports a
concrete ByteReader over a single contiguous Uint8Array (used by the
ASN.1 codecs); this is an unrelated type for an unrelated problem (decoding
over a chunk list without a single contiguous copy).
Properties
Section titled “Properties”remaining
Section titled “remaining”
readonlyremaining:number
Defined in: packages/format-core/src/byte-cursor.ts:21
Unread bytes remaining.
Methods
Section titled “Methods”contiguous()
Section titled “contiguous()”contiguous(
length):Uint8Array<ArrayBufferLike> |null
Defined in: packages/format-core/src/byte-cursor.ts:50
Contiguous window over the next length bytes when the backing allows it,
otherwise null. Lets a hot decoder take a zero-copy fast path and fall
back to readBytes only when a value straddles a chunk boundary.
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”Uint8Array<ArrayBufferLike> | null
indexOf()
Section titled “indexOf()”indexOf(
needle,from?):number
Defined in: packages/format-core/src/byte-cursor.ts:27
Index of needle relative to the cursor, or -1.
Parameters
Section titled “Parameters”needle
Section titled “needle”number | Uint8Array<ArrayBufferLike>
number
Returns
Section titled “Returns”number
peekByte()
Section titled “peekByte()”peekByte(
offset):number|undefined
Defined in: packages/format-core/src/byte-cursor.ts:24
Byte at offset from the cursor, or undefined past the end.
Parameters
Section titled “Parameters”offset
Section titled “offset”number
Returns
Section titled “Returns”number | undefined
peekBytes()
Section titled “peekBytes()”peekBytes(
length):Uint8Array
Defined in: packages/format-core/src/byte-cursor.ts:30
Copy length bytes from the cursor without advancing.
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”Uint8Array
readBytes()
Section titled “readBytes()”readBytes(
length):Uint8Array
Defined in: packages/format-core/src/byte-cursor.ts:33
Copy length bytes and advance the cursor.
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”Uint8Array
readString()
Section titled “readString()”readString(
length,encoding?):string
Defined in: packages/format-core/src/byte-cursor.ts:40
Decode length bytes as text and advance the cursor.
Parameters
Section titled “Parameters”length
Section titled “length”number
encoding?
Section titled “encoding?”TextEncodingName
Defaults to "utf-8".
Returns
Section titled “Returns”string
skip()
Section titled “skip()”skip(
length):void
Defined in: packages/format-core/src/byte-cursor.ts:43
Advance the cursor without copying.
Parameters
Section titled “Parameters”length
Section titled “length”number
Returns
Section titled “Returns”void