UI for Zipcoin Blue

shuffle.js 678B

1234567891011121314151617181920212223242526
  1. var arrayShuffle = require('./_arrayShuffle'),
  2. baseShuffle = require('./_baseShuffle'),
  3. isArray = require('./isArray');
  4. /**
  5. * Creates an array of shuffled values, using a version of the
  6. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 0.1.0
  11. * @category Collection
  12. * @param {Array|Object} collection The collection to shuffle.
  13. * @returns {Array} Returns the new shuffled array.
  14. * @example
  15. *
  16. * _.shuffle([1, 2, 3, 4]);
  17. * // => [4, 1, 3, 2]
  18. */
  19. function shuffle(collection) {
  20. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  21. return func(collection);
  22. }
  23. module.exports = shuffle;