fp/services/worker/src/util/random.ts
CJ_Clippy a5433e7bd5
Some checks failed
ci / test (push) Failing after 5m32s
fp/our CI/CD / build (push) Successful in 1m2s
rss torrent compatibility and thumbnail creation
2025-11-27 01:18:09 -08:00

11 lines
238 B
TypeScript

/**
* randomly shuffle an array
*/
export function shuffle<T>(arr: T[]): T[] {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}