diff options
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/random.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/pure/random.nim b/lib/pure/random.nim index d6501c87e..26e6740ea 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -224,8 +224,12 @@ when not defined(nimscript): proc randomize*() {.benign.} = ## Initializes the random number generator with a "random" ## number, i.e. a tickcount. Note: Does not work for NimScript. - let now = times.getTime() - randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond) + when defined(js): + let time = int64(times.epochTime() * 1_000_000_000) + randomize(time) + else: + let now = times.getTime() + randomize(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond) {.pop.} |