collection/map.js

  1. import { map as _map } from 'lodash'
  2. import { apply } from 'immutadot/core'
  3. /**
  4. * Replaces by an array of values by running each element in the former collection thru iteratee.
  5. * The iteratee is invoked with three arguments: (value, index|key, collection).
  6. * @function
  7. * @memberof collection
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#map|lodash.map} for more information.
  13. * @example map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } }
  14. * @since 1.0.0
  15. */
  16. const map = apply(_map, { arity: 1 })
  17. export { map }