1 var baseForOwn = require('./_baseForOwn'),
2 baseIteratee = require('./_baseIteratee');
5 * Creates an object with the same keys as `object` and values generated by
6 * running each own enumerable property of `object` through `iteratee`. The
7 * iteratee function is invoked with three arguments: (value, key, object).
12 * @param {Object} object The object to iterate over.
13 * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
14 * @returns {Object} Returns the new mapped object.
18 * 'fred': { 'user': 'fred', 'age': 40 },
19 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
22 * _.mapValues(users, function(o) { return o.age; });
23 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
25 * // The `_.property` iteratee shorthand.
26 * _.mapValues(users, 'age');
27 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
29 function mapValues(object, iteratee) {
31 iteratee = baseIteratee(iteratee, 3);
33 baseForOwn(object, function(value, key, object) {
34 result[key] = iteratee(value, key, object);
39 module.exports = mapValues;