Implement keyBy(arr, keyFn)
Like groupBy, but for the common case where each key is expected to be unique — write keyBy(arr, keyFn) that returns an object mapping each key to its single matching item (not an array). If two items share a key, the later one wins.
keyBy([{ id: 1, name: "Ada" }, { id: 2, name: "Grace" }], (u) => u.id);
// { 1: { id: 1, name: "Ada" }, 2: { id: 2, name: "Grace" } }