(fn = () => void 0, n = INT_0)
| 8 | * @returns {void} |
| 9 | */ |
| 10 | export function delay (fn = () => void 0, n = INT_0) { |
| 11 | // Handle null or non-function inputs |
| 12 | if (typeof fn !== "function") { |
| 13 | fn = () => void 0; |
| 14 | } |
| 15 | |
| 16 | if (n === INT_0) { |
| 17 | try { |
| 18 | fn(); |
| 19 | } catch { |
| 20 | // Swallow errors in function execution |
| 21 | } |
| 22 | } else { |
| 23 | setTimeout(() => { |
| 24 | try { |
| 25 | fn(); |
| 26 | } catch { |
| 27 | // Swallow errors in function execution |
| 28 | } |
| 29 | }, random(n)); |
| 30 | } |
| 31 | } |
no test coverage detected