array/flatMap.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces an array mapping each element using a mapping function, then flattening the result into a new array.
  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. * @see {@link https://mdn.io/Array.prototype.flatMap|Array.prototype.flatMap} for more information.
  11. * @since 2.0.0
  12. */
  13. const flatMap = applyArrayMethod('flatMap', { mutating: false })
  14. export { flatMap }