1 var baseAssignValue = require('./_baseAssignValue'),
2 baseForOwn = require('./_baseForOwn'),
3 baseIteratee = require('./_baseIteratee');
6 * Creates an object with the same keys as `object` and values generated
7 * by running each own enumerable string keyed property of `object` thru
8 * `iteratee`. The iteratee is invoked with three arguments:
9 * (value, key, object).
15 * @param {Object} object The object to iterate over.
16 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
17 * @returns {Object} Returns the new mapped object.
22 * 'fred': { 'user': 'fred', 'age': 40 },
23 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
26 * _.mapValues(users, function(o) { return o.age; });
27 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
29 * // The `_.property` iteratee shorthand.
30 * _.mapValues(users, 'age');
31 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
33 function mapValues(object, iteratee) {
35 iteratee = baseIteratee(iteratee, 3);
37 baseForOwn(object, function(value, key, object) {
38 baseAssignValue(result, key, iteratee(value, key, object));
43 module.exports = mapValues;