Skip to content

encodeCbor

encodeCbor(value): Uint8Array

Defined in: packages/format-cbor/src/binary/encoder.ts:155

Encodes a DataValue to CBOR bytes.

Always uses definite-length encoding and always encodes float as double-precision (major type 7, additional information 27) — both valid per RFC 8949 but not necessarily the shortest possible encoding (§4.1’s “preferred serialization” is not fully implemented; only argument widths are minimized). Integers outside -2^64..2^64-1 and simple values 20-23 throw CborEncodeError rather than silently promoting to a bignum tag — construct a {kind: "tag", tag: 2n | 3n, value: {kind: "bytes", ...}} node directly if a bignum is needed.

DataValue

Uint8Array