object/mapValues.js

  1. import _mapValues from 'lodash/mapValues'
  2. import convert from '../util/convert'
  3. /**
  4. * Creates an object with the same keys as object and values generated by
  5. * running each own enumerable string keyed property of object thru iteratee.
  6. * The iteratee is invoked with three arguments: (value, key, object).
  7. * @function
  8. * @memberof object
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example mapValues({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v * v) // => { nested: { a:1, b: 4, c: 9 } }
  14. * @example mapValues({ nested: { a: { age: 40, name: 'John' }, b: { age: 30, name: 'Alice' } } }, 'nested', 'age')
  15. * // => { nested: { a: 40, b: 30 } }
  16. * @see {@link https://lodash.com/docs#mapValues|lodash.mapValues} for more information.
  17. * @see {@link https://lodash.com/docs#identity|lodash.identity} for more information.
  18. * @since 0.1.12
  19. */
  20. const mapValues = convert(_mapValues)
  21. export default mapValues