Hooks
Functions
sleep
Fuction of creates a delay or pause in the execution of code for a specified number of milliseconds by returning a promise that resolves after the given time
Example
import sleep from '@/utils/sleep';
const exampleFunction = async () => {
console.log("Before sleep");
await sleep(2000); // Pauses execution for 2 seconds
console.log("After sleep");
};
exampleFunction()Params
| param | Description | Type | Default |
|---|---|---|---|
| ms | The number of milliseconds to pause the execution. | number | - |
Return
| return | Description | Type | Default |
|---|---|---|---|
| resolve | The promise resolves after the delay, allowing the execution of the next operation. | Promise | - |