import { curryN } from "@unboxing/function"; interface Nth { (n: number, list: ArrayLike): T | undefined; (n: number): (list: ArrayLike) => T | undefined; } /** * Returns the nth element of the given array. If n is negative the * element at index length + n is returned. */ export const nth = curryN(2, (index = 0, arr: ArrayLike = []) => { if (index < 0) { index += arr.length; } return arr[index]; }) as Nth