diff --git a/qjs.c b/qjs.c index 0254aa2..e612d89 100644 --- a/qjs.c +++ b/qjs.c @@ -528,11 +528,12 @@ int main(int argc, char **argv) "globalThis.global = globalThis;\n" "global.console.error = console.log\n" "global.console.warn = console.log\n" + "globalThis.break = () => { throw new Error('Break'); };\n" "\n" "if (typeof os !== 'undefined') {\n" " globalThis.sleep = os.sleep;\n" - " async function setTimeout(func, ms) { let cleared = false; await sleep(ms); if (!cleared) { func(); } return function clearTimeout() { cleared = true } }\n" - " globalThis.setTimeout = setTimeout\n" + " async function setTimeout2(func, ms) {globalThis.clearTimeout = false; await sleep(ms); if (!clearTimeout) { func(); } }\n" + " globalThis.setTimeout = setTimeout2\n" "} else {\n" " console.error('os is not defined.');\n" "}\n"