uuidv4-gen

Generate UUIDv4 strings

Usage no npm install needed!

<script type="module">
  import uuidv4Gen from 'https://cdn.skypack.dev/uuidv4-gen';
</script>

README

uuidv4-gen

A very simple library for generating RFC 4122 UUIDs, variant 4, given a source of randomness.

Usage

On the web:

let uuidv4 = require('uuidv4-gen');

let uuid = uuidv4(crypto.getRandomValues.bind(crypto));

In node:

let uuidv4 = require('uuidv4-gen');
let crypto = require('crypto');
function getRandomBytes(buffer) {
  buffer.set(crypto.randomBytes(buffer.length));
}

let uuid = uuidv4(getRandomBytes);