src/utils.js
function getNextWrappingIndex(moveAmount, baseIndex, itemCount) {
  const itemsLastIndex = itemCount - 1

  if (
    typeof baseIndex !== 'number' ||
    baseIndex < 0 ||
    baseIndex >= itemCount
  ) {
    baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1
  }
  let newIndex = baseIndex + moveAmount
  if (newIndex < 0) {
    newIndex = itemsLastIndex
  } else if (newIndex > itemsLastIndex) {
    newIndex = 0
  }
  return newIndex
}
function getNextWrappingIndex(moveAmount, baseIndex, itemCount) {
  const itemsLastIndex = itemCount - 1

  if (
    typeof baseIndex !== 'number' ||
    baseIndex < 0 ||
    baseIndex >= itemCount
  ) {
    baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1
  }
  let newIndex = baseIndex + moveAmount
  if (newIndex < 0) {
    newIndex = itemsLastIndex
  } else if (newIndex > itemsLastIndex) {
    newIndex = 0
  }
  return newIndex
}
function getNextWrappingIndex ( moveAmount , baseIndex , itemCount ) { const itemsLastIndex = itemCount - 1 if ( typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount ) { baseIndex = moveAmount > 0 ? - 1 : itemsLastIndex + 1 } let newIndex = baseIndex + moveAmount if ( newIndex < 0 ) { newIndex = itemsLastIndex } else if ( newIndex > itemsLastIndex ) { newIndex = 0 } return newIndex }
Returns the new index in the list, in a circular way. If next value is out of bonds from the total,
it will wrap to either 0 or itemCount - 1.

@param {number} moveAmount Number of positions to move. Negative to move backwards, positive forwards.
@param {number} baseIndex The initial position to move from.
@param {number} itemCount The total number of items.
@returns {number} The new index after the move.
Returns the new index in the list in a circular way . If next value is out of bonds from the total it will wrap to either 0 or itemCount - 1 .