mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 11:45:26 +03:00
cf65b2c601
* chore: add prettierrc * chore: apply format with prettier config * chore: eslint error fix
610 B
610 B
delay
Delays the execution of code for a specified number of milliseconds.
This function returns a Promise that resolves after the specified delay, allowing you to use it with async/await to pause execution.
Signature
function delay(ms: number): Promise<void>;
Parameters
ms
(number
): The number of milliseconds to delay.
Returns
(Promise<void>
): A Promise that resolves after the specified delay.
Examples
async function foo() {
console.log('Start');
await delay(1000); // Delays execution for 1 second
console.log('End');
}
foo();