mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 12:27:49 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modern modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* lodash 4.0.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
*/
|
||||
var sample = require('lodash.sample');
|
||||
var sampleSize = require('lodash.samplesize');
|
||||
|
||||
/** Used as references for `-Infinity` and `Infinity`. */
|
||||
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295;
|
||||
|
||||
/**
|
||||
* Creates an array of shuffled values, using a version of the
|
||||
@@ -17,8 +17,9 @@ var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Collection
|
||||
* @param {Array|Object|string} collection The collection to shuffle.
|
||||
* @param {Array|Object} collection The collection to shuffle.
|
||||
* @returns {Array} Returns the new shuffled array.
|
||||
* @example
|
||||
*
|
||||
@@ -26,7 +27,7 @@ var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
||||
* // => [4, 1, 3, 2]
|
||||
*/
|
||||
function shuffle(collection) {
|
||||
return sample(collection, POSITIVE_INFINITY);
|
||||
return sampleSize(collection, MAX_ARRAY_LENGTH);
|
||||
}
|
||||
|
||||
module.exports = shuffle;
|
||||
|
||||
Reference in New Issue
Block a user