Skip to content

Instantly share code, notes, and snippets.

@simonkberg
Created May 27, 2019 09:47
Show Gist options
  • Save simonkberg/56d8afab91a86a525b9a0039ed20e382 to your computer and use it in GitHub Desktop.
Save simonkberg/56d8afab91a86a525b9a0039ed20e382 to your computer and use it in GitHub Desktop.
const uuid = () => {
const arr = new Uint32Array(8);
window.crypto.getRandomValues(arr);
return arr.reduce((acc, val, idx) => acc + (idx < 2 || idx > 5 ? '' : '-') + val.toString(16).slice(-4), '');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment