array/splice.js

  1. import convertArrayMethod from './convertArrayMethod'
  2. /**
  3. * Replaces an array removing and/or adding elements at <code>index</code> in the former 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 {number} start Index at which to start changing the array.
  9. * @param {number} [deleteCount] The number of old array elements to remove.
  10. * @param {...*} values The values to add.
  11. * @return {Object} Returns the updated object.
  12. * @example splice({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 1, 2, 5, 6) // => { nested: { prop: [1, 5, 6, 4] } }
  13. * @see {@link https://mdn.io/Array.prototype.splice|Array.prototype.splice} for more information.
  14. * @since 0.2.0
  15. */
  16. const splice = convertArrayMethod('splice')
  17. export default splice