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

    Class TagsStore

    Tag registry implementation.

    Stores tags with their names and optional summarizer functions.

    Implements

    Index

    Constructors

    Methods

    • Insert a tag into the registry.

      Matches Rust's TagsStore::insert() behavior:

      • Throws if the tag name is undefined or empty
      • Throws if a tag with the same value exists with a different name
      • Allows re-registering the same tag value with the same name

      Parameters

      • tag: Tag

        The tag to register (must have a non-empty name)

      Returns void

      Error if tag has no name, empty name, or conflicts with existing registration

      const store = new TagsStore();
      store.insert(createTag(12345, 'myCustomTag'));
    • Insert multiple tags into the registry. Matches Rust's insert_all() method.

      Parameters

      • tags: Tag[]

        Array of tags to register

      Returns void

      const store = new TagsStore();
      store.insertAll([
      createTag(1, 'date'),
      createTag(100, 'custom')
      ]);
    • Register a custom summarizer function for a tag.

      Parameters

      Returns void

      store.setSummarizer(1, (cbor, flat) => {
      // Custom date formatting
      return `Date(${extractCbor(cbor)})`;
      });
    • Get the assigned name for a tag, if any.

      Parameters

      • tag: Tag

        The tag to look up

      Returns string | undefined

      The assigned name, or undefined if no name is registered

    • Get a display name for a tag.

      Parameters

      • tag: Tag

        The tag to get a name for

      Returns string

      The assigned name if available, otherwise the tag value as a string

    • Look up a tag by its name.

      Parameters

      • name: string

        The tag name

      Returns Tag | undefined

      The Tag object if found, undefined otherwise