cbor(42); // integer
cbor("héllo"); // NFC-normalized text
cbor([1, "two", true, null]); // array
cbor(new Map([["k", 1]])); // map (canonical key order)
cbor({ name: "Alice", age: 30 }); // plain object -> map
Custom - unsupported input type, or one of the two
directive errors below.
Two input shapes throw a directive CborError because encoding them
silently would produce ambiguous or divergent bytes:
{tag, value}: use
taggedValue(tag, content) for a tagged value, or add/rename a key for
a map;taggedCbor() but not toCbor(): add
toCbor() { return this.taggedCbor(); }.
Convert any supported value to its CBOR representation - the single polymorphic constructor.
Custom types participate by implementing ToCbor (
toCbor(): Cbor- thetoJSONprecedent). Tagged values are built with taggedValue.