Add unclampedSetTimeout helper

This commit is contained in:
David Császár
2024-09-01 09:37:47 +02:00
parent bbebea0fa5
commit 1c74356691

View File

@@ -41,6 +41,18 @@ getJasmineRequireObj().clearStack = function(j$) {
};
}
function getUnclampedSetTimeout(global) {
const { setTimeout } = global;
if (j$.util.isUndefined(global.MessageChannel)) return setTimeout;
const postMessage = getPostMessage(global);
return function unclampedSetTimeout(fn) {
postMessage(function() {
setTimeout(fn);
});
};
}
function getPostMessage(global) {
const { MessageChannel, setTimeout } = global;
const channel = new MessageChannel();