source: trip-planner-front/node_modules/lodash/mapValues.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var baseAssignValue = require('./_baseAssignValue'),
2 baseForOwn = require('./_baseForOwn'),
3 baseIteratee = require('./_baseIteratee');
4
5/**
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).
10 *
11 * @static
12 * @memberOf _
13 * @since 2.4.0
14 * @category 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.
18 * @see _.mapKeys
19 * @example
20 *
21 * var users = {
22 * 'fred': { 'user': 'fred', 'age': 40 },
23 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
24 * };
25 *
26 * _.mapValues(users, function(o) { return o.age; });
27 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
28 *
29 * // The `_.property` iteratee shorthand.
30 * _.mapValues(users, 'age');
31 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
32 */
33function mapValues(object, iteratee) {
34 var result = {};
35 iteratee = baseIteratee(iteratee, 3);
36
37 baseForOwn(object, function(value, key, object) {
38 baseAssignValue(result, key, iteratee(value, key, object));
39 });
40 return result;
41}
42
43module.exports = mapValues;
Note: See TracBrowser for help on using the repository browser.