MCPcopy Create free account
hub / github.com/avoidwork/tenso / delay

Function delay

src/utils/delay.js:10–31  ·  view source on GitHub ↗
(fn = () => void 0, n = INT_0)

Source from the content-addressed store, hash-verified

8 * @returns {void}
9 */
10export 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}

Callers 2

authFunction · 0.90

Calls 2

randomFunction · 0.90
fnFunction · 0.85

Tested by

no test coverage detected