mapKeys.js 781 B

12345678910111213141516171819202122232425
  1. var createObjectMapper = require('../internal/createObjectMapper');
  2. /**
  3. * The opposite of `_.mapValues`; this method creates an object with the
  4. * same values as `object` and keys generated by running each own enumerable
  5. * property of `object` through `iteratee`.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @category Object
  10. * @param {Object} object The object to iterate over.
  11. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  12. * per iteration.
  13. * @param {*} [thisArg] The `this` binding of `iteratee`.
  14. * @returns {Object} Returns the new mapped object.
  15. * @example
  16. *
  17. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  18. * return key + value;
  19. * });
  20. * // => { 'a1': 1, 'b2': 2 }
  21. */
  22. var mapKeys = createObjectMapper(true);
  23. module.exports = mapKeys;