diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-01 12:52:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-01 12:52:31 +0200 |
commit | 2c4f1b5a9a879bbefdfa6f9cf8bb72c12cd486d7 (patch) | |
tree | 89aec085bf061d439cf2205d909e5e8118c6a698 /src/js/javascript.nim | |
parent | 1b7f6849b945e28fc6418c42d8799a899d667a81 (diff) | |
download | chawan-2c4f1b5a9a879bbefdfa6f9cf8bb72c12cd486d7.tar.gz |
Add setTimeout, setInterval to window
Diffstat (limited to 'src/js/javascript.nim')
-rw-r--r-- | src/js/javascript.nim | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index 438858ef..c6459956 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -245,6 +245,13 @@ proc writeException*(ctx: JSContext, s: Stream) = JS_FreeValue(ctx, stack) JS_FreeValue(ctx, ex) +proc runJSJobs*(rt: JSRuntime, err: Stream) = + while JS_IsJobPending(rt): + var ctx: JSContext + let r = JS_ExecutePendingJob(rt, addr ctx) + if r == -1: + ctx.writeException(err) + func isInstanceOf*(ctx: JSContext, obj: JSValue, class: string): bool = let clazz = ctx.getClass(class) if clazz in ctx.getOpaque().ctors: |