Pauses execution for the specified number of milliseconds

⚠️ NOTE: Requires an active event loop to function

// In your code:
async function main() {
console.log('Starting');
await asyncSleep(1000); // Wait for 1 second
console.log('Done');
}

void main();

// Make sure you have an event loop running!
runOsEventLoop();
  • Parameters

    • ms: number

      The number of milliseconds to sleep

    Returns Promise<void>