source: imaps-frontend/node_modules/lodash-es/mapValues.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import baseAssignValue from './_baseAssignValue.js';
2import baseForOwn from './_baseForOwn.js';
3import baseIteratee from './_baseIteratee.js';
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
43export default mapValues;
Note: See TracBrowser for help on using the repository browser.