[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user