Is there a better way to engineer a sleep in JavaScript than the following pausecomp function (taken from here