20 lines
477 B
JavaScript
20 lines
477 B
JavaScript
|
|
const sleep = (ms, fn) => {return setTimeout(fn, ms)};
|
|
|
|
const range = (start, end, length = end - start + 1) => {
|
|
return Array.from({length}, (_, i) => start + i)
|
|
}
|
|
|
|
const random = (min, max) => {
|
|
return Math.floor(Math.random() * (max - min)) + min;
|
|
}
|
|
|
|
const shuffle = (arr) => {
|
|
for (let i = arr.length - 1; i > 0; i--) {
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
const temp = arr[i];
|
|
arr[i] = arr[j];
|
|
arr[j] = temp;
|
|
}
|
|
}
|