How to make synchronous pause in javascript code by UI command?

Good day. I am running JS code via executeScript. How to pause 1000 ms from this code with a UI command?

Hi, can you please post the JS code that you are using?

Good day. Thanks so much. I found the soft synchronous decission.

sleeptime = 500 // ms
function* clock()
{
    let i = 0
    while( true )
    {
        i++
        main(); // main function
        setTimeout(
            ()=>
            {
                clk.next()
            }
            , sleeptime
        )
        yield
    }
}
let clk = clock()
clk.next()

For synchronous example, it will make - main(), than 500 ms pause, than main() etc.