array/fill.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces by an array filled with value from start up to, but not including, end.
  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 {*} value The value to fill array with.
  9. * @param {number} [start=0]
  10. * @param {number} [end=array.length]
  11. * @return {Object} Returns the updated object.
  12. * @example fill({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 6, 1, 3) // => { nested: { prop: [1, 6, 6, 4] } }
  13. * @see {@link https://mdn.io/Array.prototype.fill|Array.prototype.fill} for more information.
  14. * @since 0.3.0
  15. */
  16. const fill = applyArrayMethod('fill')
  17. export { fill }