type MapOptions = { /** * Allow merging existing keys or not, if not keys will be overriden if they exist * (default=false) * * Example: * mapFnAsMap([{uid: 12, a: 'hi'}, {uid: 12, b: 'ho'}], el => el.uid, {merge: true}) * Output: * {12: {uid: 12, a: 'hi', b: 'ho'}} * Output if merge is false * {12: {uid: 12, b: 'ho'}} */ merge?: boolean; /** * A custom transform function that is applied to each element before mapping. * Its output type `U` becomes the value type of the resulting map. */ transform_fn?: (el: T) => U; }; type MapFn> = (entry: T) => string | number | null; /** * Map an object array into a Map through a function that generates a key. Returning a non-string, * non-numeric value from the function (eg: null) will filter out the object. * * Example: * mapFnAsMap([{uid: 12, name: 'Peter'}, {uid: 15, name: 'Jonas'}], el => el.uid); * Output: * new Map([ * [12, {uid: 12, name: 'Peter'}], * [15, {uid: 15, name: 'Jonas'}], * ]) * * @param {Record[]} val - Array to map * @param {MapFn} fn - Handler function which is run for each of the objects and should return a string or number * @param {MapOptions?} opts - Options object to override built-in defaults */ declare function mapFnAsMap, TFN extends MapFn, U extends Record = T>(arr: T[], fn: TFN, opts?: MapOptions): Map>, U>; export { mapFnAsMap, mapFnAsMap as default };