source: node_modules/es-toolkit/dist/compat/function/delay.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[a762898]1/**
2 * Invokes the specified function after a delay of the given number of milliseconds.
3 * Any additional arguments are passed to the function when it is invoked.
4 *
5 * @param {(...args: any[]) => any} func - The function to delay.
6 * @param {number} wait - The number of milliseconds to delay the invocation.
7 * @param {...any[]} args - The arguments to pass to the function when it is invoked.
8 * @returns {number} Returns the timer id.
9 * @throws {TypeError} If the first argument is not a function.
10 *
11 * @example
12 * // Example 1: Delayed function execution
13 * const timerId = delay(
14 * (greeting, recipient) => {
15 * console.log(`${greeting}, ${recipient}!`);
16 * },
17 * 1000,
18 * 'Hello',
19 * 'Alice'
20 * );
21 * // => 'Hello, Alice!' will be logged after one second.
22 *
23 * // Example 2: Clearing the timeout before execution
24 * clearTimeout(timerId);
25 * // The function will not be executed because the timeout was cleared.
26 */
27declare function delay(func: (...args: any[]) => any, wait: number, ...args: any[]): number;
28
29export { delay };
Note: See TracBrowser for help on using the repository browser.