Advertisement
3MoSteve

UUID Generator huh.

Jan 26th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. const a = () => {
  2. let a = '';
  3. for (let i = 0; i < 32; i += 1) {
  4. if ([8, 12, 16, 20].includes(i)) {
  5. a += '-';
  6. }
  7. let n;
  8. if (i == 12) {
  9. n = 4;
  10. } else {
  11. const d = Math.random() * 16 | 0;
  12. if (i == 16) {
  13. n = (d & 3) | 0;
  14. } else {
  15. n = d;
  16. }
  17. }
  18. a += n.toString(16);
  19. }
  20. return a;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement