Open History to see the last commit
1export async function loaderDelayFn<T>(
2 fn: (...args: Array<any>) => Promise<T> | T,
3) {
4 const delay = Number(sessionStorage.getItem('loaderDelay') ?? 0)
5 const delayPromise = new Promise((r) => setTimeout(r, delay))
6β
7 await delayPromise
8 const res = await fn()
9β
10 return res
11}
12β
13export async function actionDelayFn<T>(
14 fn: (...args: Array<any>) => Promise<T> | T,
15) {
16 const delay = Number(sessionStorage.getItem('actionDelay') ?? 0)
17 await new Promise((r) => setTimeout(r, delay))
18 return fn()
19}
20β
21export function shuffle<T>(arr: Array<T>): Array<T> {
22 let i = arr.length
23 if (i == 0) return arr
24 const copy = [...arr]
25 while (--i) {
26 const j = Math.floor(Math.random() * (i + 1))
27 const a = copy[i]
28 const b = copy[j]
29 copy[i] = b!
30 copy[j] = a!
31 }
32 return copy
33}