Skip to main content
Version: Next

delay

Using

Creates a delay for a specified number of milliseconds and returns a resolved promise after the delay.

Arguments

ArgumentTypeDescriptionExample
msnumberThe input milliseconds0
1000

Returns

Promise — Promise void

Examples

delay(2000).then(() => {
console.log('2 seconds have passed');
});
// Wait for 2 seconds

delay().then(() => {
console.log('No delay');
});
// Default delay (0 milliseconds)

(async () => {
await delay(1000);
console.log('1 second has passed');
})();
// Wait for 1 second using async/await

Resources

📦 Since:1.2.0
📦 Last updated:1.2.0
📦 Available in:1.3.0