BC-DCBOR TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class CborMap

    A deterministic CBOR map implementation.

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

    Index

    Constructors

    • Creates a new, empty CBOR Map. Optionally initializes from a JavaScript Map.

      Parameters

      • Optionalmap: Map<unknown, unknown>

      Returns CborMap

    Accessors

    • get length(): number

      Returns the number of entries in the map. Matches Rust's Map::len().

      Returns number

    • get size(): number

      Alias for length to match JavaScript Map API. Also matches Rust's Map::len().

      Returns number

    • get entriesArray(): MapEntry[]

      Get the entries of the map as an array. Keys are sorted in lexicographic order of their encoded CBOR bytes.

      Returns MapEntry[]

    • get debug(): string

      Returns string

    • get diagnostic(): string

      Returns string

    Methods

    • Get a value from the map, given a key. Returns undefined if the key is not present in the map. Matches Rust's Map::get().

      Type Parameters

      Parameters

      • key: K

      Returns V | undefined

    • Get a value from the map, given a key. Throws an error if the key is not present. Matches Rust's Map::extract().

      Type Parameters

      Parameters

      • key: K

      Returns V

    • Tests if the map contains a key. Matches Rust's Map::contains_key().

      Type Parameters

      Parameters

      • key: K

      Returns boolean

    • Returns the number of entries in the map. Matches Rust's Map::len().

      Returns number

    • Checks if the map is empty. Matches Rust's Map::is_empty().

      Returns boolean

    • Gets an iterator over the entries of the CBOR map, sorted by key. Key sorting order is lexicographic by the key's binary-encoded CBOR. Matches Rust's Map::iter().

      Returns MapEntry[]

    • Returns an iterator of [key, value] tuples for JavaScript Map API compatibility. This matches the standard JavaScript Map.entries() method behavior.

      Returns IterableIterator<[Cbor, Cbor]>

    • 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. Matches Rust's Map::insert_next().

      Type Parameters

      Parameters

      • key: K
      • value: V

      Returns void