type MapOptions = { /** * Allow merging existing keys or not, if not keys will be overriden if they exist * (default=false) * * Example: * mapFn([{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 | boolean); /** * Map an object array into a kv-object through a function that generates a key. Returning a non-string, * non-numeric value from the function (eg: false) will filter out the object. * * Example: * mapFn([{uid: 12, name: 'Peter'}, {uid: 15, name: 'Jonas'}], el => el.uid); * Output: * {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 mapFn, U extends Record = T>(arr: T[], fn: MapFn, opts?: MapOptions): Record; export { mapFn, mapFn as default };