lodash.shuffle
Advanced tools
Comparing version 3.0.0 to 3.1.0
30
index.js
/** | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* 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/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
var baseRandom = require('lodash._baserandom'), | ||
toIterable = require('lodash._toiterable'); | ||
var sample = require('lodash.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 Fisher-Yates | ||
* shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) | ||
* for more details. | ||
* Creates an array of shuffled values, using a version of the | ||
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). | ||
* | ||
@@ -28,18 +29,5 @@ * @static | ||
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; |
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -4,0 +4,0 @@ |
{ | ||
"name": "lodash.shuffle", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "The modern build of lodash’s `_.shuffle` as a module.", | ||
@@ -20,5 +20,4 @@ "homepage": "https://lodash.com/", | ||
"dependencies": { | ||
"lodash._baserandom": "^3.0.0", | ||
"lodash._toiterable": "^3.0.0" | ||
"lodash.sample": "^3.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.shuffle v3.0.0 | ||
# lodash.shuffle v3.1.0 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.shuffle` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#shuffle) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.shuffle) for more details. | ||
See the [documentation](https://lodash.com/docs#shuffle) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.shuffle) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
3803
29
+ Addedlodash.sample@^3.0.0
+ Addedlodash._arraycopy@3.0.0(transitive)
+ Addedlodash._isiterateecall@3.0.9(transitive)
+ Addedlodash.sample@3.1.0(transitive)
+ Addedlodash.toarray@3.0.2(transitive)
+ Addedlodash.values@3.0.0(transitive)
- Removedlodash._baserandom@^3.0.0
- Removedlodash._toiterable@^3.0.0