UNPKG

@thi.ng/arrays

Version:

Array / Arraylike utilities

8 lines (7 loc) 252 B
import { ensureIndex } from "@thi.ng/errors/out-of-bounds"; const lookup = (table, ids) => ids.map((i) => (ensureIndex(i, 0, table.length), table[i])); const lookupUnsafe = (table, ids) => ids.map((i) => table[i]); export { lookup, lookupUnsafe };