Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "array/get-wrap-around-at"

Index

Functions

Functions

getWrapAroundAt

  • getWrapAroundAt<T, A>(array: A, index: number): A extends Readonly<NonEmptyArray<T>> ? T : T | undefined
  • Gets an element in the array wrapping around (both ways), so -1 would be the last element, and length would warp to 0.

    Type parameters

    • T

    • A: ReadonlyArray<T>

    Parameters

    • array: A

      The array to use to get items from.

    • index: number

      Index to get in this array, if it is out of bounds (index < 0 or index >= this.length), we will "wrap" that index around to be in range.

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

    Element at the index, wrapped around when out of range. If the array is empty undefined is returned.

Generated using TypeDoc