You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
410 B
20 lines
410 B
export default function(x) {
|
|
return typeof x === "object" && "length" in x
|
|
? x // Array, TypedArray, NodeList, array-like
|
|
: Array.from(x); // Map, Set, iterable, string, or anything else
|
|
}
|
|
|
|
export function shuffle(array, random) {
|
|
let m = array.length,
|
|
t,
|
|
i;
|
|
|
|
while (m) {
|
|
i = random() * m-- | 0;
|
|
t = array[m];
|
|
array[m] = array[i];
|
|
array[i] = t;
|
|
}
|
|
|
|
return array;
|
|
}
|
|
|