Skip to content

DataValue

DataValue = { kind: "int"; value: bigint; } | { kind: "float"; value: number; } | { kind: "bytes"; value: Uint8Array; } | { kind: "text"; value: string; } | { items: readonly DataValue[]; kind: "array"; } | { entries: readonly readonly [DataValue, DataValue][]; kind: "map"; } | { kind: "tag"; tag: bigint; value: DataValue; } | { kind: "bool"; value: boolean; } | { kind: "null"; } | { kind: "undefined"; } | { kind: "simple"; value: number; }

Defined in: packages/format-cbor/src/ast.ts:9

The CBOR generic data model (RFC 8949 §2) — the single value tree shared by the binary codec, the diagnostic-notation codec, and the JSON bridge.

Integers and floating-point values are distinct even when numerically equal (RFC 8949 §2), so int always carries a bigint and float always carries a JS number (binary64) — never conflated.

{ kind: "int"; value: bigint; }


{ kind: "float"; value: number; }


{ kind: "bytes"; value: Uint8Array; }


{ kind: "text"; value: string; }


{ items: readonly DataValue[]; kind: "array"; }


{ entries: readonly readonly [DataValue, DataValue][]; kind: "map"; }


{ kind: "tag"; tag: bigint; value: DataValue; }


{ kind: "bool"; value: boolean; }


{ kind: "null"; }


{ kind: "undefined"; }


{ kind: "simple"; value: number; }

An unassigned simple value (RFC 8949 §3.3), 0-19 or 32-255.