Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ArrayUtils

Index

Methods

Static findIndex

  • findIndex<T>(array: T[], predicate: function): number
  • Type parameters

    • T

    Parameters

    • array: T[]
    • predicate: function
        • (T: any): boolean
        • Parameters

          • T: any

          Returns boolean

    Returns number

Static mapWithErrorCallback

  • mapWithErrorCallback<T, U>(array: T[], callback: function, errCallback: function, thisArg?: any): U[]
  • Similar to Array.map, except that any time that an item in the input causes the callback function to throw an error, an error handler will be invoked rather than aborting. These items will be skipped in the output, so unlike Array.map(), it's possible that the output array may contain a different number of items from the input.

    Type parameters

    • T

    • U

    Parameters

    • array: T[]
    • callback: function
        • (T: any): U
        • Parameters

          • T: any

          Returns U

    • errCallback: function
        • (item: T, error: Error, result: U[]): void
        • Parameters

          • item: T
          • error: Error
          • result: U[]

          Returns void

    • Optional thisArg: any

    Returns U[]

Static max

  • max<T>(items: T[], callback: function): any
  • Calculates the maximum of all items based on a callback selector value.

    Type parameters

    • T

    Parameters

    • items: T[]
    • callback: function
        • (item: T): any
        • Parameters

          • item: T

          Returns any

    Returns any

Static sortBy

  • sortBy<T>(items: Array<T>, selector: function): Array<T>
  • Sorts an array based on a particular property or function value.

    Type parameters

    • T

    Parameters

    • items: Array<T>
    • selector: function
        • (item: T): any
        • Parameters

          • item: T

          Returns any

    Returns Array<T>

Static spliceMany

  • spliceMany(items: Array<any>, indicies: number[]): void
  • Remove many items from an array in the most efficient manner possible

    Parameters

    • items: Array<any>

      The source array. Will be changed.

    • indicies: number[]

      The indicies to remove from the array.

    Returns void

Static sum

  • sum<T>(items: T[], callback: function): number
  • Calculates the sum of all items based on a callback selector value.

    Type parameters

    • T

    Parameters

    • items: T[]
    • callback: function
        • (item: T): number
        • Parameters

          • item: T

          Returns number

    Returns number

Static unique

  • unique<T>(items: Array<T>): Array<T>
  • Returns unique values found in an array of numbers or strings.

    Type parameters

    • T: number | string

    Parameters

    • items: Array<T>

      The raw array of values

    Returns Array<T>