ethers.js/packages/random/lib.esm/shuffle.js

12 lines
323 B
JavaScript
Raw Normal View History

"use strict";
export function shuffled(array) {
array = array.slice();
for (let i = array.length - 1; i > 0; i--) {
2019-11-20 12:57:38 +03:00
const j = Math.floor(Math.random() * (i + 1));
const tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
return array;
}
2020-07-13 15:03:56 +03:00
//# sourceMappingURL=shuffle.js.map