Scripts/resources/[ps]/ps-ui/html/js/utils.js

20 lines
477 B
JavaScript
Raw Permalink Normal View History

2024-12-29 20:28:24 +00:00
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;
}
}