delay
Pauses asynchronous code for a given number of milliseconds, often useful for delaying actions within an async function.> delay(ms: number = 2000): Promise<void>
- ms: The number of milliseconds to wait.
- Returns: A Promise that resolves after the specified time.
Example
import { delay } from "@explita/daily-toolset";
async function delayedTask() {
console.log("Starting task...");
await delay(1000);
console.log("Task finished after delay");
}
delayedTask();