UNPKG

265 BJavaScriptView Raw
1export function nth(index, list){
2 if (arguments.length === 1) return _list => nth(index, _list)
3
4 const idx = index < 0 ? list.length + index : index
5
6 return Object.prototype.toString.call(list) === '[object String]' ?
7 list.charAt(idx) :
8 list[ idx ]
9}