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.

25 lines 642 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayIndex = void 0; /** * @public * Populates a `Map` given a key creating function and `ArrayLike`. * * @remarks * keys which are null are omitted. * * See {@link arrayIndex}. */ 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; } exports.arrayIndex = arrayIndex; //# sourceMappingURL=array-index.js.map