Skip to main content

Function: sleepSync()

sleepSync<T>(ms: number, value?: T): T

Sleeps for the specified number of milliseconds synchronously. We should probably note that unlike sleep (which uses CPU tick times), sleepSync uses wall clock times, so the precision is near-absolute by comparison. That, and that synchronous means that nothing else in the thread will run for the length of the timer.

For an asynchronous variant, see sleep.

Type parameters

Type parameterValue
Tundefined

Parameters

ParameterTypeDescription
msnumberThe number of milliseconds to sleep.
value?TA value to return.

Returns

T

See

sleep for an asynchronous version.

Source

lib/sleepSync.ts:12