/** * @public * Populates a `Map` given a key creating function and `ArrayLike`. * * @remarks * keys which are null are omitted. * * See {@link arrayIndex}. */ export function arrayIndex ( items: ArrayLike, getKey: (item: TItem, index: number) => TKey | null ) : Map, TItem> { const indexed = new Map, TItem>(); for (let i = 0, iEnd = items.length; i < iEnd; ++i) { const item = items[i]; const key = getKey(item, i); if (key !== null) { indexed.set(key as Exclude, item); } } return indexed; }