Created
January 27, 2020 10:00
-
-
Save HassakuTb/499deae556698d9d7d003da9b6a54820 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export const generateUuid: () => string = () =>{ | |
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("") | |
.map(c =>{ | |
if(c === "x"){ | |
return Math.floor(Math.random() * 16).toString(16); | |
} | |
else if(c === "y"){ | |
return Math.floor(Math.random() * 4 + 8).toString(16); | |
} | |
else{ | |
return c; | |
} | |
}) | |
.join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment