array/pullAt.js

  1. import _pullAt from 'lodash/pullAt'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces an array removing the specified indexes from 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|number[])} [indexes] The indexes of elements to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pullAt({ nested: { prop: [4, 3, 2, 1] } }, 'nested.prop', 1, 3) // => { nested: { prop: [4, 2] } }
  12. * @see {@link https://lodash.com/docs#pullAt|lodash.pullAt} for more information.
  13. * @since 0.3.0
  14. */
  15. const pullAt = convert((array, predicate) => {
  16. _pullAt(array, predicate)
  17. return array
  18. })
  19. export { pullAt, pullAt as default }