array/take.js

  1. import { take as _take } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with <code>n</code> elements taken from the beginning.
  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] Number of elements to take from the beginning of the array.
  10. * @return {Object} Returns the updated object.
  11. * @example take({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#take|lodash.take} for more information.
  13. * @since 1.0.0
  14. */
  15. const take = convert(_take)
  16. export { take }