Sleeps for a given number of milliseconds.
The number of milliseconds to sleep.
Optional
The abort signal to listen to.
Whether to throw an error if the sleep is aborted.
A promise that resolves after the given number of milliseconds.
sleep(1000) // Waits for 1 secondsleep(500) // Waits for 0.5 secondssleep(1000, signal, true) // Throws an error if the sleep is abortedsleep(1000, signal, false) // Resolves without throwing an error Copy
sleep(1000) // Waits for 1 secondsleep(500) // Waits for 0.5 secondssleep(1000, signal, true) // Throws an error if the sleep is abortedsleep(1000, signal, false) // Resolves without throwing an error
Sleeps for a given number of milliseconds.