UNPKG

@extra-array/get

Version:
9 lines (8 loc) 185 B
'use strict'; function index(x, i = 0) { return i < 0 ? Math.max(x.length + i, 0) : Math.min(i, x.length); } function get(x, i) { return x[index(x, i)]; } module.exports = get;