From f5663d383e0c0c8363e40b878663b20c463a1b35 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 8 Sep 2024 19:01:58 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index a7474f8..c95564e 100644 --- a/readme.md +++ b/readme.md @@ -90,26 +90,27 @@ You can change the underlying PRNG or its seed as follows: ```ts // change the underlying pseudo random number generator seed. // by default, Math.random is used as the underlying PRNG, but it is not seedable, -// so if a seed is given, we use an ARC4 PRNG. +// so if a seed is given, we use an ARC4 PRNG (the same one used by `seedrandom`). random.use('my-seed') -// create a new independent random number generator (uses ARC4 under the hood) +// create a new independent random number generator with a different seed const rng = random.clone('my-new-seed') -// create a second independent random number generator using a custom PRNG +// create a third independent random number generator using a custom PRNG import seedrandom from 'seedrandom' -const rng2 = random.clone(seedrandom('kittyfoo')) +const rng2 = random.clone(seedrandom('kitty-seed')) ``` You can also instantiate a fresh instance of `Random`: ```ts import { Random } from 'random' -import seedrandom from 'seedrandom' const rng = new Random() // (uses Math.random) const rng2 = new Random('my-seed-string') -const rng3 = new Random(seedrandom('my-seed-string')) +const rng3 = new Random(() => { + /* custom PRNG */ return Math.random() +}) ``` ## API