Provides extra examples of how various additional operations can be added on top of HashArray. These operations are not included with HashArray to keep it lean and mean for TrieSearch. By all means though extend HashArray and add the operations that you need.

There are tests for all operations below in ./test/hash/HAExtra.test.ts.

Constructors

Methods

  • Iterates deeply over items specified by key and index with an optional weightKey and calculates the average value.

    Type Parameters

    • T extends object

    Parameters

    • source: HashArray<T>

      Source HashArray.

    • key: Key

      The Key to retrieve item(s) to iterate.

    • index: Key

      A specific Key in each item to lookup.

    • OptionalweightKey: Key

      A specific Key in each item to provide a weighting value.

    Returns number

    The average value for the given iteration.

  • Returns the difference of this HashArray and a target HashArray. If no output HashArray is provided the source is cloned.

    Type Parameters

    • T extends object

    Parameters

    Returns HashArray<T>

    Returns a new HashArray that contains the difference between source (A) and target (B) HashArrays. Returns A - B.

  • Iterates deeply over items specified by key and index with an optional weightKey and calculates the sum.

    Type Parameters

    • T extends object

    Parameters

    • source: HashArray<T>

      Source HashArray.

    • key: Key

      The Key to retrieve item(s) to iterate.

    • index: Key

      A specific Key in each item to lookup.

    • OptionalweightKey: Key

      A specific Key in each item to provide a weighting value.

    Returns number

    The sum for the given iteration.