Initial ES modules support
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user