Hey man, how are you?
You may try to call Date.now() on every tick within while loop and check against your target value like so:
var td = {
"setTimeout": function (callback, ms) {
var dt = new Date();
var i = dt.getTime();
var future = i + ms;
while(Date.now() <= future) {
//do nothing - blocking
}
return callback();
}
};