@newdash/newdash
Version:
javascript/typescript utility library
29 lines (28 loc) • 1.01 kB
TypeScript
import { PlainObject, CollectionIteratee, KeyIteratee } from "./types";
/**
* Creates an object with the same keys as `object` and values generated
* by running each own enumerable string keyed property of `object` thru
* `iteratee`. The iteratee is invoked with three arguments:
* (value, key, object).
*
* @since 5.11.0
* @category Object
* @param object The object to iterate over.
* @param iteratee The function invoked per iteration.
* @returns Returns the new mapped object.
* @see [[mapKeys]]
* @example
*
* ```js
* const users = {
* 'fred': { 'user': 'fred', 'age': 40 },
* 'pebbles': { 'user': 'pebbles', 'age': 1 }
* }
*
* mapValue(users, ({ age }) => age)
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
* ```
*/
export declare function mapValues<T>(object: PlainObject<T>, iteratee: KeyIteratee): PlainObject;
export declare function mapValues<T>(object: PlainObject<T>, iteratee: CollectionIteratee<T>): PlainObject;
export default mapValues;