Add a seedable UUIDv4 generator
Most UUID generators assume that you want fully random UUIDs. In most cases, this is true. The `uuid` package allows a consumer to pass in `random` values (an array of 16 numbers 0-255), or a generator that outputs 16 random bytes. This is our hook into being able to provide "random" values. We just need a way to get "random" values that are actually random in most cases, but that we can control if we want to. Enter: the Mersenne Twister. Mersenne Twisters can be seeded with a number to start. They will derive all of their future twisted states from that initial seed. So: we still get "randomness," but we can also seed it to make the output deterministic. This `random.js` file outputs a single function (for now) called `uuids` that will generate a random UUIDv4 string or - if provided seeds - will generate the correct resulting UUIDv4 given those seeds. Consumers can request multiple values to avoid having to constantly call the function and/or constantly reconstruct the internal Twister.
Showing
Please register or sign in to comment