Get the number of elements in the set.
Number of elements
StaticfromStaticfromStaticfromInsert an element into the set.
If the element already exists, has no effect.
Value to insert
Check if set contains an element.
Value to check
true if element is in the set
Remove an element from the set.
Value to remove
true if element was removed, false if not found
Remove all elements from the set.
Check if the set is empty.
true if set has no elements
Check if this set is a subset of another set.
Other set
true if all elements of this set are in the other set
Check if this set is a superset of another set.
Other set
true if all elements of the other set are in this set
Iterate over elements in the set.
Elements are returned in deterministic order (by CBOR encoding).
Execute a function for each element.
Function to call for each element
Returns the CBOR tags associated with this type.
This method should return an array of tags in order of preference:
The first tag in the array is the "preferred" tag and will be used
when encoding values of this type via
CborTaggedEncodable.taggedCbor().
All tags in the array are considered equivalent for decoding. When
CborTaggedDecodable.fromTaggedCbor() is called, any tag in this
array will be accepted as valid for this type.
This design enables backward compatibility: you can introduce a new tag (placed first in the array) while still supporting older tags for decoding.
For standard CBOR tags, you can use predefined tag constants from the
tags module, or create custom tags with createTag().
Returns the untagged CBOR encoding of this instance.
This method defines how the value itself (without its tag) should be represented in CBOR format.
Untagged CBOR representation
Returns the tagged CBOR encoding of this instance.
This method wraps the result of untaggedCbor() with the first tag
from cborTags(), which is considered the "preferred" tag for the
type.
Even if a type supports multiple tags for backward-compatible decoding
via cborTags(), only the first (preferred) tag is used for encoding.
This ensures consistency in newly created data while maintaining the
ability to read older formats.
In most cases, you don't need to override this method.
Tagged CBOR representation
Creates an instance of this type by decoding it from tagged CBOR.
This method first verifies that the CBOR value has one of the expected
tags (as defined by cborTags()), then delegates to
fromUntaggedCbor() to decode the content.
For backward compatibility, this method accepts any tag from the
cborTags() array, not just the first one. This allows new
versions of types to still accept data tagged with older/alternative
tag values.
In most cases, you don't need to override this method.
Decoded instance
StaticfromConvert to CBOR bytes (tagged).
Encoded CBOR bytes
Convert to JavaScript Array.
Array with extracted values
Convert to string (same as diagnostic).
String representation
Convert to JSON (returns array of values).
Array for JSON serialization
CBOR Set type with tag(258) encoding.
Internally uses a CborMap to ensure unique elements with deterministic ordering. Elements are ordered by their CBOR encoding (lexicographic byte order).
Example