array/dropRight.js

  1. import _dropRight from 'lodash/dropRight'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces an array dropping one or several elements at the end of the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] The number of elements to drop.
  10. * @return {Object} Returns the updated object.
  11. * @example dropRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#dropRight|lodash.dropRight} for more information.
  13. * @since 0.3.0
  14. */
  15. const dropRight = convert(_dropRight)
  16. export { dropRight, dropRight as default }