UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

21 lines 510 B
/** * @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, getKey) { const indexed = new Map(); 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, item); } } return indexed; } //# sourceMappingURL=array-index.js.map