Skip to main content

setClockTimeout()

setClockTimeout(cb, ms): () => void

Works the same way as setTimeout but will wait to fire until next clock second.

Parameters

cb

() => void

The callback to execute after each duration.

ms

number

The time, in ms, between callback execution.

Returns

Function

A function to clear the timeout.

Returns

void

Example

const cleanup = setClockTimeout(() => console.log('hi'), 250);
// will log hi after 250ms starting on next clock second