summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-09-09 20:20:40 +0800
committerGitHub <noreply@github.com>2024-09-09 14:20:40 +0200
commit3a55bae53fe80728ce625dd5366aee5da9cf6463 (patch)
tree0f1855da16e640c1d20037d2b66f117d06105c4b /lib
parentfcee829d85605d6d401f15966a283b0041631308 (diff)
downloadNim-3a55bae53fe80728ce625dd5366aee5da9cf6463.tar.gz
enable closures tests for JS & implement `finished` for JS (#23521)
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/system.nim b/lib/system.nim
index aeeda831f..5f4847b7d 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2350,8 +2350,14 @@ when notJSnotNims:
`result` = `x`.ClE_0;
""".}
- proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magic: "Finished".} =
- ## It can be used to determine if a first class iterator has finished.
+proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magic: "Finished".} =
+ ## It can be used to determine if a first class iterator has finished.
+ when defined(js):
+ # TODO: mangle `:state`
+ {.emit: """
+ `result` = (`x`.ClE_0).HEX3Astate < 0;
+ """.}
+ else:
{.emit: """
`result` = ((NI*) `x`.ClE_0)[1] < 0;
""".}