Skip to main content
Version: v0.0.6

Function: uuid()

uuid(rng): string

A deterministic UUIDv4-shaped surrogate key from the seeded generator. Because it is seeded (not from node:crypto, which is not reproducible), the cryptographic non-collision argument is weaker - acceptable because the identifier namespace is synthetic anyway, and noted honestly.

Parameters

rng

Rng

The seeded generator.

Returns

string

A canonical 8-4-4-4-12 lowercase-hex UUID string with version 4 and RFC 4122 variant.

Example

import { createRng, uuid } from "@cosyte/synth";
uuid(createRng(1)); // "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"