Initial ES modules support

This commit is contained in:
2026-10-26 12:39:58 +00:00
parent f7c5b2c80f
commit 1e12e7be2e
35 changed files with 1266 additions and 505 deletions
+5 -2
View File
@@ -4,7 +4,10 @@
//
// Not as the spec says: `setTimeout` takes no args for the callback
function setTimeout(f, ms) {
import { __native_io_queue_cancel, __native_io_queue_timeout } from "jsrt:native";
import { __pending } from "jsrt:loop";
export function setTimeout(f, ms) {
// As in node, a delay below 1 ms is 1 ms
const delay = ms === undefined || !(ms >= 1) ? 1 : ms;
const timer = { handle: __native_io_queue_timeout(delay), active: true };
@@ -18,7 +21,7 @@ function setTimeout(f, ms) {
return timer;
}
function clearTimeout(timer) {
export function clearTimeout(timer) {
if (timer === undefined || timer === null || !timer.active) return;
timer.active = false;
__native_io_queue_cancel(timer.handle);