[jsscripting] Implement NodeJS-like parameter handling for timer polyfills (#15193)

* [jsscripting] Implement NodeJS-like param handling for timer polyfills
* [jsscripting] Clean-Up ThreadsafeTimer methods

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze
2023-07-07 23:10:35 +02:00
committed by GitHub
parent 7a8ef1fdcc
commit 2d75536f48
2 changed files with 6 additions and 30 deletions

View File

@@ -163,9 +163,13 @@
// Polyfill common NodeJS functions onto the global object
globalThis.console = console;
globalThis.setTimeout = ThreadsafeTimers.setTimeout;
globalThis.setTimeout = function (functionRef, delay, ...args) {
ThreadsafeTimers.setTimeout(() => functionRef(...args), delay);
};
globalThis.clearTimeout = ThreadsafeTimers.clearTimeout;
globalThis.setInterval = ThreadsafeTimers.setInterval;
globalThis.setInterval = function (functionRef, delay, ...args) {
ThreadsafeTimers.setInterval(() => functionRef(...args), delay);
};
globalThis.clearInterval = ThreadsafeTimers.clearInterval;
// Support legacy NodeJS libraries