UNPKG

@writetome51/array-get-head-tail

Version:

Functions that return either a number of items from the beginning of the array, or the end

8 lines (4 loc) 261 B
import {getAdjacentAt} from '@writetome51/array-get-adjacent-at'; export const getHead = (numItemsToGet, array) => getAdjacentAt(0, numItemsToGet, array); export const getTail = (numItemsToGet, array) => getAdjacentAt(-numItemsToGet, numItemsToGet, array);