type MapOptions = { /** * Allow merging existing keys or not, if not keys will be overriden if they exist * (default=false) * * Example: * mapKey([{uid: 12, a: 'hi'}, {uid: 12, b: 'ho'}], 'uid', {merge: true}) * Output: * {12: {uid: 12, a: 'hi', b: 'ho'}} * Output if merge is false * {12: {uid: 12, b: 'ho'}} */ merge?: boolean; /** * Pass a custom filter function which will be run in O(n) while iterating */ filter_fn?: (el: T) => boolean; /** * A custom transformer function to modify each element before mapping. * Its output type `U` becomes the value type of the resulting map. */ transform_fn?: (el: T) => U; }; /** * Map an object array into a Map by passing a common key that exists on the objects. Objects for * which the key doesn't exist will be filtered out automatically * * Example: * mapKey([{uid: 12, name: 'Peter'}, {uid: 15, name: 'Jonas'}], 'uid'); * Output: * new Map([ * [12, {uid: 12, name: 'Peter'}], * [15, {uid: 15, name: 'Jonas'}], * ]) * * @param {Record[]} val - Array to map * @param {string} key - Key to map by * @param {MapOptions?} opts - Options object to override built-in defaults */ declare function mapKeyAsMap, U extends Record = T, TKey extends keyof T = string>(arr: T[], key: TKey, opts?: MapOptions): Map; export { mapKeyAsMap, mapKeyAsMap as default };