Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sleep

Pauses execution for the specified number of milliseconds. This utility function wraps setTimeout in a Promise, allowing for async/await syntax when you need to introduce delays in your MOD code.

Parameters

  • ms (number): Number of milliseconds to pause execution

Returns

A Promise that resolves after the specified time has elapsed.

Examples

Basic Usage

// Simple delay
console.log('Starting...');
await Deno.api.functions.sleep(2000);
console.log('2 seconds later!');
  • runtime - Environment detection for timing behavior
  • Commands - Event timing and throttling
  • Effects - Visual effect timing and synchronization