fix(shuffle): fix shuffle methode for array with length <= 1
This commit is contained in:
@@ -5,12 +5,15 @@ function rndNext(min, max) {
|
||||
}
|
||||
|
||||
function shuffle (arr, from, to) {
|
||||
if (!to) {
|
||||
to = arr.length - 1;
|
||||
if (arr.length <= 1){
|
||||
return arr;
|
||||
}
|
||||
if (!from) {
|
||||
from = 0;
|
||||
}
|
||||
if (!to) {
|
||||
to = arr.length - 1;
|
||||
}
|
||||
const newArr = [...arr];
|
||||
if (from >= to) return;
|
||||
for (var current = from; current <= to; ++current) {
|
||||
|
Reference in New Issue
Block a user