Skip to content

decodeCborItem

decodeCborItem(buffer, offset?): CborItemDecodeResult

Defined in: packages/format-cbor/src/binary/decoder.ts:216

Attempts to decode one top-level CBOR data item starting at offset.

Modeled on @ac-kit/format-core’s incremental DecodeResult (this package’s answer to whether a “Lexer” should be a streaming class or an eager tokenize-to-array function — CBOR is self-delimiting but an item’s total length isn’t known until it is fully parsed, which is exactly the shape that needs an incremental result instead of an eager array). Unlike DecodeResult, incomplete carries no needAtLeast — the recursive descent has no cheap way to compute one; a caller retries once more bytes arrive. CborItemDecoder adapts this to the Decoder contract directly, for driving via decodeAll/DecodeStream.

Uint8Array

number = 0

CborItemDecodeResult