deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

`v4` uuid generation

Open adriannsemb opened this issue 10 months ago • 1 comments

Hi there,

I think it would be great if we could re-add the simple globalThis.crypto.randomUUID() as the v4 uuid generation.

It currently feels very weird to me that there doesn't exist a generation v4 among the @std/uuid module, mainly because I would assume it contains it. I was about to use npm:uuid instead, because I didn't even know of crypto.randomUUID() (which I think might be the case for multiple users).

Related: https://github.com/denoland/std/issues/5156

  • If we want polyfill, we can expand on such implementation, but a simple wrapper would be very nice IMO.

Also, I think the following reads much better (of course a preference):

import { v4 } from "jsr:@std/uuid";

const uuid = v4.generate();

Than:

const uuid = crypto.randomUUID();

and my expectation would simply be that a uuid library can generate v4 uuid.

adriannsemb avatar Mar 04 '25 13:03 adriannsemb

To me, users not knowing about widely known API in crypto.randomUUID isn't a sufficient reason to re-implement an API that the runtime already has. Also, the existence of crypto.randomUUID is clearly stated in the module documentation for @std/uuid.

iuioiua avatar Mar 29 '25 05:03 iuioiua