UNPKG

react-hotkeys

Version:

A declarative library for handling hotkeys and focus within a React application

13 lines (12 loc) 470 B
/** * Returns the element in an array at a particular index from the end * @param {Array.<T>} array Array to iterate over to find the item * @param {number} placesFromEnd Number of places from the end of the array to find * the item to return * @returns {T} The item found in the array at the particular index * @template T */ function indexFromEnd(array, placesFromEnd) { return array[array.length - (placesFromEnd + 1)]; } export default indexFromEnd;