c7abdf25071f5a4233e4926a9ae5f8e1cf97c6d7
[yaffs-website] / node_modules / uncss / node_modules / lodash / shuffle.js
1 var sampleSize = require('./sampleSize');
2
3 /** Used as references for the maximum length and index of an array. */
4 var MAX_ARRAY_LENGTH = 4294967295;
5
6 /**
7  * Creates an array of shuffled values, using a version of the
8  * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9  *
10  * @static
11  * @memberOf _
12  * @category Collection
13  * @param {Array|Object} collection The collection to shuffle.
14  * @returns {Array} Returns the new shuffled array.
15  * @example
16  *
17  * _.shuffle([1, 2, 3, 4]);
18  * // => [4, 1, 3, 2]
19  */
20 function shuffle(collection) {
21   return sampleSize(collection, MAX_ARRAY_LENGTH);
22 }
23
24 module.exports = shuffle;