Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "array/get-wrap-around"

Index

Functions

Functions

getWrapAround

  • getWrapAround<T, A>(array: A, element: T, offset?: undefined | number): A extends ReadonlyArray<NonEmptyArray<T>> ? T : T | undefined
  • Returns the next element in the array by some offset, wrapping around if it would walk off the array.

    Type parameters

    • T

    • A: ReadonlyArray<T>

    Parameters

    • array: A

      The array to get something in wrapping around.

    • element: T

      Element in the array to find the index of.

    • Optional offset: undefined | number

      From the element's position where to move, up or down and will wrap around.

    Returns A extends ReadonlyArray<NonEmptyArray<T>> ? T : T | undefined

    Undefined if the element was not in this array, or the element at the offset from the passed in element in the array, wrapping around.

Generated using TypeDoc