Javascript JS : Updating DOM in a long running blocking function

Javascript JS : Updating DOM in a long running blocking function

See code in:
https://github.com/vpelss/primes
https://raw.githubusercontent.com/vpelss/primes/master/index.html

Look for:
//place after each dom update so it shows in blocking function
// 'await sleep(0)' pauses async GetPrimes on stack and puts sleep's promise on the microtask loop so a dom update can run
function sleep(ms)
{
//return new Promise(resolve => setTimeout(resolve, ms));
return new Promise(function(resolve, reject)
{
setTimeout(function(){resolve('foo');}, 0);
});
};