@blockchaincommons/dcbor - v1.0.0-beta.1
    Preparing search index...

    A deterministic CBOR map implementation.

    Maps are always encoded with keys sorted lexicographically by their encoded CBOR representation, ensuring deterministic encoding.

    Index
    • get "[toStringTag]"(): string

      Debug label: Object.prototype.toString reports [object CborMap].

      Returns string

    • get size(): number

      The number of entries in the map.

      Returns number

    • get entriesArray(): MapEntry[]
      Internal

      Get the entries of the map as an array, sorted in canonical ascending encoded-key order.

      Public because the encoder, diagnostic formatter, and hex annotator consume it cross-module; not part of the supported surface.

      Returns MapEntry[]

    • Inserts a key-value pair into the map (replacing any entry whose key has the same canonical encoding). Any insertion order is accepted - entries are kept in canonical ascending encoded-key order.

      Parameters

      Returns void

      const m = new CborMap();
      m.set("z", 1);
      m.set(10, "ten"); // sorts before "z" in the encoding
      encodeCbor(m); // deterministic regardless of insertion order
    • Get the STORED Cbor node for a key, or undefined if absent.

      This is symmetric with entries() - no hidden native extraction, no unwitnessed generics. To read a native value, compose explicitly:

      asNumber(map.get("age"));          // number | undefined, checked
      extractCbor(map.getOrThrow("age")); // CborNative, throws if absent

      Parameters

      Returns Cbor | undefined

    • Iterate keys in canonical (sorted encoded-key) order.

      Returns Generator<Cbor, void, undefined>

    • Iterate values in canonical key order.

      Returns Generator<Cbor, void, undefined>

    • Iterate [key, value] tuples in canonical key order (the JS Map.entries() shape).

      Returns Generator<[Cbor, Cbor], void, undefined>

    • JS Map.forEach mirror (value first, then key, then the map).

      Parameters

      • callback: (value: Cbor, key: Cbor, map: CborMap) => void
      • OptionalthisArg: unknown

      Returns void

    • Internal

      Inserts the next key-value pair into the map during decoding. This is used for efficient map building during CBOR decoding. Throws if the key is not in ascending order or is a duplicate.

      The decoder's append path; not part of the supported surface.

      Parameters

      Returns void