collection/shuffle.js

  1. import { shuffle as _shuffle } from 'lodash'
  2. import { apply } from 'immutadot/core'
  3. /**
  4. * Replaces by an array of shuffled elements.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @see {@link https://lodash.com/docs#shuffle|lodash.shuffle} for more information.
  11. * @example shuffle({ nested: { prop: [1, 2, 3, 4, 5, 6, 7, 8, 9] } }, 'nested.prop') // => { nested: { prop: [7, 3, 9, 1, 4, 5, 6, 8, 2] } }
  12. * @since 1.0.0
  13. */
  14. const shuffle = apply(
  15. _shuffle,
  16. {
  17. arity: 1,
  18. fixedArity: true,
  19. },
  20. )
  21. export { shuffle }