array/map.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces by an array of values by running each element in the former collection thru callback.
  4. * @function
  5. * @memberof array
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @param {function} callback The function invoked per iteration.
  9. * @return {Object} Returns the updated object.
  10. * @example map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } }
  11. * @see {@link https://mdn.io/Array.prototype.map|Array.prototype.map} for more information.
  12. * @since 1.0.0
  13. */
  14. const map = applyArrayMethod('map', { mutating: false })
  15. export { map }