v2 / vlib / rand / sys / system_rng.js.v
15 lines · 13 sloc · 521 bytes · 763f94388b1ceff59c3e68ebda2c9f57197f32a4
Raw
1// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4module sys
5
6// Until there's a portable, JS has a seeded way to produce random numbers
7// and not just Math.random(), use any of the existing implementations
8// as the System's RNG
9type SysRNG = WyRandRNG
10
11// In the JS version, we simply return the same int as is normally generated.
12@[inline]
13pub fn (r SysRNG) default_rand() int {
14 return r.int()
15}
16