solarnetwork-api-core
    Preparing search index...

    Class MultiMap

    A case-insensitive, case-preserving string key multi-value map object.

    This map supports null values but ignores attempts to add keys with undefined values.

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructor.

      Parameters

      • Optionalvalues: Record<string, any>

        an object who's enumerable properties will be added to this map

      Returns MultiMap

    Methods

    • Add a value.

      This method will append values to existing keys.

      Parameters

      • key: string

        the key to use

      • value: any

        the value to add; if undefined nothing will be added

      Returns this

    • Test if there are any values associated with a key.

      Parameters

      • key: string

        the key to test

      Returns boolean

      true if there is at least one value associated with the key

    • Get the first avaialble value assocaited with a key.

      Parameters

      • key: string

        the key of the value to get

      Returns any

      the first available value associated with the key, or undefined if not available

    • Get an array of all keys in this map.

      Returns string[]

      array of keys in this map, or an empty array if the map is empty

    • Get the entire mapping as a single-valued Map instance.

      This will return the first avaialble value for every key in the mapping.

      Returns Map<string, any>

      a new Map instance

    • Set a value.

      This method will replace any existing values with just value.

      Parameters

      • key: string

        the key to use

      • value: any

        the value to set; if undefined nothing will be added

      Returns this

      this object

    • Set multiple values.

      This method will replace any existing values with those provided on values.

      Parameters

      • values: Record<string, any>

        an object who's enumerable properties will be added to this map

      Returns this

      this object

    • Remove all values associated with a key.

      Parameters

      • key: string

        the key of the values to remove

      Returns undefined | any[]

      the removed values, or undefined if no values were present for the given key

    • Get the values associated with a key.

      Parameters

      • key: string

        the key of the values to get

      Returns undefined | any[]

      the array of values associated with the key, or undefined if not available