Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/arrays

Index

Functions

Const arrayMove

  • arrayMove(array: any[], from: number, to: number): any[]
  • Moves the item at index from to index to. Returns a new instance of the array with the item moved.

    Implementation and tests adapted from https://www.npmjs.com/package/array-move. This helper was built to replace our reliance on this dependency.

    Parameters

    • array: any[]
    • from: number
    • to: number

    Returns any[]

    Copy of array with the item moved.

Const getOrderingFunctionForObject

  • getOrderingFunctionForObject<T>(orderDirection: "asc" | "desc", orderBy: keyof T): (a: T, b: T) => number
  • description

    Gets compare function for object orders by ascending or descending based on input param 'orderDirection'

    Type parameters

    • T: object

    Parameters

    • orderDirection: "asc" | "desc"
    • orderBy: keyof T

    Returns (a: T, b: T) => number

    • sorting compareFn
      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

Const orderByObjectProperty

  • orderByObjectProperty<T>(a: T, b: T, orderBy: keyof T): number
  • description

    Private function to order an array according to the orderBy property

    Type parameters

    • T

    Parameters

    • a: T

      first value to compare

    • b: T

      second value to compare

    • orderBy: keyof T

      Object property to order by

    Returns number

Generated using TypeDoc