Dreamdata Shared Utils & Constants - v1.19.0
    Preparing search index...

    Class ArrayUtils

    Index

    Constructors

    Methods

    • Creates all possible permutations of elements in first array and second. Elements within same array are not permutated.

      Type Parameters

      • X
      • Y
      • T

      Parameters

      • xs: X[]
      • ys: Y[]
      • combineFunction: (x: X, y: Y) => T

      Returns T[]

    • Finds all values that are in xs but not in ys

      Type Parameters

      • T

      Parameters

      • xs: T[]
      • ys: T[]
      • getValue: Fn<T, string | number>

      Returns T[]

    • Picks number in array nearest value

      Parameters

      • value: number
      • candidates: number[]

      Returns number

    • Removes duplicate values from an array.

      Type Parameters

      • T

      Parameters

      • values: T[]

        The array to deduplicate.

      Returns T[]

      A new array with unique values.

    • Sorts an object array by a field

      Type Parameters

      • T extends object

      Parameters

      • data: T[]
      • getValue: Fn<T, string> | Fn<T, number> | Fn<T, Date>
      • direction: Direction = "ASC"

      Returns T[]

    • Sorts an array of objects by a numeric field.

      Type Parameters

      • T extends object

      Parameters

      • data: T[]

        The array of objects to sort.

      • getValue: Fn<T, number>

        Function to extract the numeric value from each object.

      • direction: Direction = "ASC"

        Sort direction, either "ASC" or "DESC" (default: "ASC").

      Returns T[]

      A new sorted array.

    • Sorts an array of objects by a string field.

      Type Parameters

      • T extends object

      Parameters

      • data: T[]

        The array of objects to sort.

      • getValue: Fn<T, string>

        Function to extract the string value from each object.

      • direction: Direction = "ASC"

        Sort direction, either "ASC" or "DESC" (default: "ASC").

      Returns T[]

      A new sorted array.

    • Splits array into array of elements before value and elements after it. If value is not found in array, all of array is return as elements before.

      Type Parameters

      • T

      Parameters

      • array: T[]
      • value: T
      • predicate: (a: T, b: T) => boolean

      Returns [T[], T[]]