source: trip-planner-front/node_modules/lodash/mapKeys.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[6a3a178]1var baseAssignValue = require('./_baseAssignValue'),
2 baseForOwn = require('./_baseForOwn'),
3 baseIteratee = require('./_baseIteratee');
4
5/**
6 * The opposite of `_.mapValues`; this method creates an object with the
7 * same values as `object` and keys generated by running each own enumerable
8 * string keyed property of `object` thru `iteratee`. The iteratee is invoked
9 * with three arguments: (value, key, object).
10 *
11 * @static
12 * @memberOf _
13 * @since 3.8.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 _.mapValues
19 * @example
20 *
21 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
22 * return key + value;
23 * });
24 * // => { 'a1': 1, 'b2': 2 }
25 */
26function mapKeys(object, iteratee) {
27 var result = {};
28 iteratee = baseIteratee(iteratee, 3);
29
30 baseForOwn(object, function(value, key, object) {
31 baseAssignValue(result, iteratee(value, key, object), value);
32 });
33 return result;
34}
35
36module.exports = mapKeys;
Note: See TracBrowser for help on using the repository browser.