@blockchaincommons/dcbor - v1.0.0-beta.1
    Preparing search index...
    • Convert any supported value to its CBOR representation - the single polymorphic constructor.

      Custom types participate by implementing ToCbor (toCbor(): Cbor - the toJSON precedent). Tagged values are built with taggedValue.

      Parameters

      Returns Cbor

      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

      OutOfRange - bigint outside [-(2^64), 2^64 - 1].

      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:

      • plain objects shaped exactly {tag, value}: use taggedValue(tag, content) for a tagged value, or add/rename a key for a map;
      • objects implementing taggedCbor() but not toCbor(): add toCbor() { return this.taggedCbor(); }.