array/flat.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces an array by a new array with all sub-array elements concatenated into it recursively up to the specified depth.
  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 {number} [depth] Depth level.
  9. * @return {Object} Returns the updated object.
  10. * @see {@link https://mdn.io/Array.prototype.flat|Array.prototype.flat} for more information.
  11. * @since 2.0.0
  12. */
  13. const flat = applyArrayMethod('flat', { mutating: false })
  14. export { flat }