File size: 410 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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;
}
|