Bump to v3.9.2.

This commit is contained in:
jdalton
2015-05-24 01:44:03 -07:00
parent b6f9660ab0
commit 314048b069
23 changed files with 169 additions and 92 deletions

View File

@@ -1,5 +1,7 @@
var baseRandom = require('../internal/baseRandom'),
toIterable = require('../internal/toIterable');
var sample = require('./sample');
/** Used as references for `-Infinity` and `Infinity`. */
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
/**
* Creates an array of shuffled values, using a version of the
@@ -16,20 +18,7 @@ var baseRandom = require('../internal/baseRandom'),
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
collection = toIterable(collection);
var index = -1,
length = collection.length,
result = Array(length);
while (++index < length) {
var rand = baseRandom(0, index);
if (index != rand) {
result[index] = result[rand];
}
result[rand] = collection[index];
}
return result;
return sample(collection, POSITIVE_INFINITY);
}
module.exports = shuffle;