Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "geocortex/framework/utils/ArrayUtils"

Index

Functions

contains

  • contains(array: any[], obj: any): boolean
  • Checks whether or not an array contains a specific object.

    Parameters

    • array: any[]

      The array to check.

    • obj: any

      The object to check for.

    Returns boolean

difference

  • difference<T>(first: T[], second: T[]): T[]
  • Produces the set difference of two sequences by using the default equality comparer to compare values. The source sequence remains unaltered.

    Type parameters

    • T

    Parameters

    • first: T[]

      An array whose elements that are not also in second will be returned.

    • second: T[]

      An array whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

    Returns T[]

distinct

  • distinct<TSource>(source: TSource[]): TSource[]
  • Returns distinct elements from a sequence by using the default equality comparer to compare values. The source sequence remains unaltered.

    Type parameters

    • TSource

    Parameters

    • source: TSource[]

      The sequence to remove duplicate elements from.

    Returns TSource[]

firstOrDefault

  • firstOrDefault<TSource>(source: TSource[], predicate?: function): TSource
  • Returns the first element in a sequence that satisfies a specified condition.

    Type parameters

    • TSource

    Parameters

    • source: TSource[]

      The sequence of values to return an element from.

    • Optional predicate: function

      A function to test each element for a condition.

        • (element: TSource, index?: number): boolean
        • Parameters

          • element: TSource
          • Optional index: number

          Returns boolean

    Returns TSource

flatten

  • flatten<T>(array: T[][]): T[]
  • Flattens an array of arrays into a single array of items, e.g. flatten([[1,2], [3], [4,5,6]]) == [1,2,3,4,5,6]. The original array is not modified.

    Type parameters

    • T

    Parameters

    • array: T[][]

      The array to flatten.

    Returns T[]

groupBy

  • groupBy<TSource, TKey>(source: TSource[], keySelector: function): Grouping<TKey, TSource>[]
  • Groups the elements of a sequence according to a specified key selector function. The source sequence remains unaltered.

    Type parameters

    • TSource

    • TKey

    Parameters

    • source: TSource[]

      The sequence whose elements to group.

    • keySelector: function

      A function to extract the key for each element.

        • (element: TSource): TKey
        • Parameters

          • element: TSource

          Returns TKey

    Returns Grouping<TKey, TSource>[]

lastOrDefault

  • lastOrDefault<TSource>(source: TSource[], predicate?: function): TSource
  • Returns the last element in a sequence that satisfies a specified condition.

    Type parameters

    • TSource

    Parameters

    • source: TSource[]

      The sequence of values to return an element from.

    • Optional predicate: function

      A function to test each element for a condition.

        • (element: TSource, index?: number): boolean
        • Parameters

          • element: TSource
          • Optional index: number

          Returns boolean

    Returns TSource

orderBy

  • orderBy<TSource, TKey>(source: TSource[], keySelector: function): TSource[]
  • Sorts the elements of a sequence in ascending order according to a key. The source sequence remains unaltered.

    Type parameters

    • TSource

    • TKey

    Parameters

    • source: TSource[]

      The sequence of values to order.

    • keySelector: function

      A function to extract the key for each element.

        • (element: TSource): TKey
        • Parameters

          • element: TSource

          Returns TKey

    Returns TSource[]

orderByDescending

  • orderByDescending<TSource, TKey>(source: TSource[], keySelector: function): TSource[]
  • Sorts the elements of a sequence in descending order according to a key. The source sequence remains unaltered.

    Type parameters

    • TSource

    • TKey

    Parameters

    • source: TSource[]

      The sequence of values to order.

    • keySelector: function

      A function to extract the key for each element.

        • (element: TSource): TKey
        • Parameters

          • element: TSource

          Returns TKey

    Returns TSource[]

pos

  • pos(array: any[], obj: any): number
  • Returns the index of a given object, if it exists in an array.

    Parameters

    • array: any[]

      The Array to check.

    • obj: any

      The object to check for.

    Returns number

remove

  • remove(array: any[], from: number, to?: number): any[]
  • Removes a range of items from an Array.

    Parameters

    • array: any[]

      The Array to remove from.

    • from: number

      The index to begin removing from.

    • Optional to: number

      The index to remove to.

    Returns any[]

removeItem

  • removeItem(array: any[], obj: any): any[]
  • Removes a specific item from an array. If multiple instances of the item exist in the array, only the first reference is removed.

    Parameters

    • array: any[]

      The array to remove from.

    • obj: any

      The object to remove.

    Returns any[]

returnTop

  • returnTop(collection: object, top: number): any[][]
  • Given an associative array of numbers keyed by strings, returns an array of 'top' tuples ([string][number]) sorted by the number

    Parameters

    • collection: object

      the collection to sort

      • [index: string]: number
    • top: number

      the number of items to return

    Returns any[][]