Skip to content

Instantly share code, notes, and snippets.

@HassakuTb
Created January 27, 2020 10:00
Show Gist options
  • Save HassakuTb/499deae556698d9d7d003da9b6a54820 to your computer and use it in GitHub Desktop.
Save HassakuTb/499deae556698d9d7d003da9b6a54820 to your computer and use it in GitHub Desktop.
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