This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generates a universally unique identifier based on random values and timestamp. | |
* Random length can be increased to get even more unique values. | |
*/ | |
function uuid() { | |
if (!window.crypto) throw new Error('crypto not available') | |
const randomLength = 8 | |
const uuidUint8Array = new Uint8Array(randomLength) | |
window.crypto.getRandomValues(uuidUint8Array) | |
return `${uuidUint8Array.join('')}${Date.now()}` |
OlderNewer