array/slice.js

  1. import _slice from 'lodash/slice'
  2. import { convert } from 'util/convert'
  3. /**
  4. * Replaces an array by a slice of the former array from <code>start</code> up to, but not including, <code>end</code>.
  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} [start=0] The start position.
  10. * @param {number} [end=array.length] The end position.
  11. * @return {Object} Returns the updated object.
  12. * @example slice({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 1, 3) // => { nested: { prop: [2, 3] } }
  13. * @see {@link https://lodash.com/docs#slice|lodash.slice} for more information.
  14. * @since 0.3.0
  15. */
  16. const slice = convert(_slice)
  17. export { slice, slice as default }