Class LiveDMap<K, V>

The LiveDMap<K, V>() class live version of DMap This usually return from live data sources e.g. databases

Type Parameters

  • K extends string

  • V = any

Hierarchy

  • DMap<K, V>
    • LiveDMap

Constructors

  • The DMap<K, V>() class encapsulates any object and provides utility method.

    Type Parameters

    • K extends string

    • V = any

    Parameters

    • content: Record<K, V> | [K, V][] | Record<K, V>[]

    Returns LiveDMap<K, V>

Properties

content: Record<K, V>

Methods

  • The filter() method filters records' key, value, which the matching function returned true.

    Parameters

    • matcher: ((k: K, v: V) => boolean)

      Matching function matches records' under provided condition.

        • (k: K, v: V): boolean
        • Parameters

          • k: K
          • v: V

          Returns boolean

    Returns DMap<K, V>

  • The findKeys() method finds records' key, which the matching function returned true.

    Parameters

    • matcher: ((v: V) => boolean)

      Matching function matches records' value under provided condition.

        • (v: V): boolean
        • Parameters

          • v: V

          Returns boolean

    Returns K[]

  • The findValues() method finds records' value, which the matching function returned true.

    Parameters

    • matcher: ((v: V) => boolean)

      Matching function matches records' value under provided condition.

        • (v: V): boolean
        • Parameters

          • v: V

          Returns boolean

    Returns V[]

  • The get() method accesses the value of the given key.

    Parameters

    • key: K

      Provided key.

    Returns undefined | V

  • The groupBy() method groups records by located values using keyLocator.

    Type Parameters

    • G extends string

    Parameters

    • keyLocator: ((v: V) => G)

      Key locator function finds the value that will be an object key.

        • (v: V): G
        • Parameters

          • v: V

          Returns G

    Returns DMap<G, Record<K, V>[]>

  • The hasKey() method checks if the record contained a given key.

    Parameters

    • c: K

      Key that being searched.

    Returns boolean

  • The hasValue() method checks if the record contained a given value.

    Parameters

    • c: V

      Value that being searched.

    Returns boolean

  • The insert() method insert new value to the map and assign temporary uuid. For the document-based database, an inserted key-value will be created after changes are pushed to the server.

    Parameters

    • value: V

      Provided value.

    Returns void

  • The iterate() method iterates through record's key and value.

    Parameters

    • c: ((key: K, value: V, index: number, obj: Record<K, V>) => Promise<void>)

      Function that is called for every element of arr. Each time callbackFn executes.

        • (key: K, value: V, index: number, obj: Record<K, V>): Promise<void>
        • Parameters

          • key: K
          • value: V
          • index: number
          • obj: Record<K, V>

          Returns Promise<void>

    Returns Promise<void>

  • The iterateSync() method synchronously iterates through record's key and value.

    Parameters

    • c: ((key: K, value: V, index: number, obj: Record<K, V>) => void)

      Function that is called for every element of arr. Each time callbackFn executes.

        • (key: K, value: V, index: number, obj: Record<K, V>): void
        • Parameters

          • key: K
          • value: V
          • index: number
          • obj: Record<K, V>

          Returns void

    Returns void

  • The keyDiff() method finds records' key, which different from elements in the given array.

    Parameters

    • comparable: string[]

      Provided keys array.

    Returns K[]

  • The keyMatch() method finds records' key, which matched with elements in the given array.

    Parameters

    • comparable: string[]

      Provided keys array.

    Returns K[]

  • The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

    Type Parameters

    • R

    Parameters

    • c: ((key: K, value: V, index: number, obj: Record<K, V>) => R)

      Function that is called for every element of arr. Each time callbackFn executes, the returned value is added to newArray.

        • (key: K, value: V, index: number, obj: Record<K, V>): R
        • Parameters

          • key: K
          • value: V
          • index: number
          • obj: Record<K, V>

          Returns R

    Returns R[]

  • The set() method set new key to the map.

    Parameters

    • key: K

      Provided key.

    • value: V

      Provided value.

    Returns void

  • The sort() method sorts the elements of an array in place and returns the sorted array. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.

    Parameters

    • c: ((a: [K, V], b: [K, V]) => number)

      Specifies a function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character's Unicode code point value.

        • (a: [K, V], b: [K, V]): number
        • Parameters

          • a: [K, V]
          • b: [K, V]

          Returns number

    Returns DMap<K, V>

Generated using TypeDoc