Class UcMeta

Charge metadata consisting of attributes and their values.

Metadata instance is mutable, unless frozen. When frozen, each modification method call returns new, mutable clone. When mutable, each modification method call returns this instance.

Applies copy-on-write technique to avoid excessive data copying.

Hierarchy

Constructors

  • Constructs new metadata instance.

    Parameters

    • Optional source: UcMeta

      Source metadata to clone the contents of.

      Optional
    • frozen: boolean = false

      Whether to freeze constructed metadata. false by default.

    Returns UcMeta

Accessors

Methods

  • Adds named attribute value to this metadata.

    Parameters

    • attribute: string

      Target attribute name.

    • value: unknown

      Value to add.

    Returns Mutable

    Modified metadata instance containing both attributes of this instance and the added ones.

  • Adds typed attribute value to this metadata.

    Type Parameters

    • TInput

      Attribute input type.

    Parameters

    • attribute: UcMetaAttr<unknown, TInput, unknown>

      Target attribute.

    • value: TInput

      Value to add.

    Returns Mutable

    Modified metadata instance containing both attributes of this instance and the added ones.

  • Obtains the value of the named attribute.

    If attribute has multiple values, then returns the last one.

    Parameters

    • attribute: string

      Target attribute name.

    Returns unknown

    Either attribute value, or undefined if there is no such attribute.

  • Extracts the typed value of the attribute.

    Type Parameters

    • T

      Attribute value type.

    Parameters

    • attribute: UcMetaAttr<T, unknown, unknown>

      Target attribute.

    Returns undefined | T

    Either attribute value, or undefined if attribute value can not be extracted.

  • Obtains all values of the named attribute.

    Parameters

    • attribute: string

      Target attribute name.

    Returns unknown[]

    Either array of attribute values, or empty array if there is no such attribute.

  • Extracts all typed values of the attribute.

    Type Parameters

    • T

      Attribute value type.

    Parameters

    • attribute: UcMetaAttr<T, unknown, unknown>

      Target attribute.

    Returns T[]

    Either array of attribute values, or empty array attribute values can not be extracted.

Generated using TypeDoc