Created
February 25, 2020 18:30
-
-
Save garenyondem/4fadf0c16be25a4ee1628f454ba66294 to your computer and use it in GitHub Desktop.
Create uuid
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
export function uuid() { | |
let rnd: number, val: { toString: (arg0: number) => string }; | |
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { | |
rnd = (Math.random() * 16) | 0; | |
val = c === "x" ? rnd : (rnd & 0x3) | 0x8; | |
return val.toString(16); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment