array/shift.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces by an array of elements with first element removed.
  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. * @return {Object} Returns the updated object.
  9. * @example shift({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop') // => { nested: { prop: [2, 3, 4] } }
  10. * @see {@link https://mdn.io/Array.prototype.shift|Array.prototype.shift} for more information.
  11. * @since 1.0.0
  12. */
  13. const shift = applyArrayMethod('shift', { fixedArity: true })
  14. export { shift }