@blockchaincommons/dcbor - v1.0.0-beta.3
    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.

      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

    • Internal

      The stored entry at position i in canonical ascending encoded-key order; the caller keeps i within [0, size).

      Positional access for the encoder and for structural equality, which walk a map (or two maps in lockstep) without materializing entriesArray; not part of the supported surface.

      Parameters

      • i: number

      Returns MapEntry

    • Internal

      The encoded CBOR bytes of the key at position i - the bytes the entry is sorted by, computed once when it was inserted.

      The encoder writes these directly, as the reference's Map::cbor_data writes its stored MapKey, instead of re-encoding the key node; not part of the supported surface.

      Parameters

      • i: number

      Returns Uint8Array

    • 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

      Append a key-value pair whose encoded key must sort strictly after every existing key.

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

      Parameters

      Returns void

      DuplicateMapKey for a repeated key, MisorderedMapKey for a key out of ascending order.