Comparing version 0.3.1 to 0.3.2
@@ -213,1 +213,6 @@ /** | ||
export declare function groupSequential<T>(items: T[], areEqual?: (a: T, b: T) => boolean): T[][]; | ||
/** | ||
Shuffle the array {xs} in-place, using the Durstenfeld variation on the | ||
Fisher-Yates algorithm. | ||
*/ | ||
export declare function shuffle<T>(xs: T[]): T[]; |
18
index.js
@@ -397,1 +397,19 @@ "use strict"; | ||
exports.groupSequential = groupSequential; | ||
/** | ||
Shuffle the array {xs} in-place, using the Durstenfeld variation on the | ||
Fisher-Yates algorithm. | ||
*/ | ||
function shuffle(xs) { | ||
var n = xs.length; | ||
var last = n - 1; | ||
for (var i = 0; i < last; i++) { | ||
// generate integer j such that 0 ≤ j < (n - i) | ||
var j = Math.random() * (n - i) | 0; | ||
// exchange xs[i] and xs[j] | ||
var xs_i = xs[i]; | ||
xs[i] = xs[j]; | ||
xs[j] = xs_i; | ||
} | ||
return xs; | ||
} | ||
exports.shuffle = shuffle; |
{ | ||
"name": "tarry", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Utility library for manipulating JavaScript Arrays", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
19019
552