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

    CBOR Set type, encoded as a plain (untagged) array.

    Internally uses a CborMap to ensure unique elements with deterministic ordering. Elements are ordered by their CBOR encoding (lexicographic byte order).

    const set = CborSet.from([3, 1, 2, 2]);
    set.add(4);
    set.has(2); // true
    encodeCbor(set); // untagged array [1, 2, 3, 4] in canonical byte order
    Index
    • get "[toStringTag]"(): string

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

      Returns string

    • get size(): number

      The number of elements in the set.

      Returns number

    • Create a CborSet from any iterable of encodable items. Duplicates (by canonical encoding) are removed.

      NOTE: strings are iterable - CborSet.from("abc") is a THREE-element set of one-character strings, not a single-element set. Wrap in an array (CborSet.from(["abc"])) for the latter.

      Parameters

      Returns CborSet

    • Add an element to the set (no effect if an element with the same canonical encoding already exists). Returns this for chaining, like JS Set.add.

      Parameters

      Returns this

    • Internal

      Add an element that must sort strictly after every element added so far (canonical CBOR-byte order). The decoder uses this to reject misordered or duplicate elements.

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

      Parameters

      Returns void

      MisorderedMapKey if value would not preserve strict ascending CBOR-byte order, or DuplicateMapKey for an exact repeat.

    • Check whether the set contains an element (by canonical encoding).

      Parameters

      Returns boolean

    • Remove an element from the set.

      Parameters

      Returns boolean

      true if the element was removed, false if not found

    • Remove all elements from the set.

      Returns void

    • Check if every element of this set is in the other set.

      Parameters

      Returns boolean

    • Check if every element of the other set is in this set.

      Parameters

      Returns boolean

    • Returns Generator<Cbor, void, undefined>

    • Iterate the stored Cbor elements lazily in canonical order.

      NOTE: this yields the stored Cbor nodes. Use toArray() for an eager array of extracted native values.

      Returns Generator<Cbor, void, undefined>

    • JS Set.keys() mirror - identical to values().

      Returns Generator<Cbor, void, undefined>

    • JS Set.entries() mirror - [value, value] tuples.

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

    • JS Set.forEach mirror (value twice, then the set).

      Parameters

      • callback: (value: Cbor, value2: Cbor, set: CborSet) => void
      • OptionalthisArg: unknown

      Returns void

    • Encode the set as an (untagged) CBOR array of its elements, in canonical ascending CBOR-byte order.

      Returns Cbor

    • Decode a CborSet from a CBOR array into this instance.

      Calls addNext per item, so the array must already be in strict ascending CBOR-byte order with no duplicates (else MisorderedMapKey/DuplicateMapKey).

      Parameters

      Returns CborSet

      WrongType if c is not an array.

    • The ToCbor protocol: encodes as the untagged canonical array.

      Returns Cbor

    • Encode straight to deterministic CBOR bytes.

      Returns Uint8Array<ArrayBuffer>

    • Convert to a string listing the extracted elements.

      Returns string