Created
October 23, 2017 08:02
-
-
Save s-melnikov/8c49e1c55ca25433aca00921320cb19e to your computer and use it in GitHub Desktop.
Test
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
const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
const uniqid = () => { | |
let now = Date.now(), chars = [], i = 8, id | |
while (i--) { | |
chars[i] = CHARS.charAt(now % 64) | |
now = Math.floor(now / 64) | |
} | |
id = chars.join("") | |
while (i++ < 8) { | |
id += CHARS.charAt(Math.floor(Math.random() * 64)) | |
} | |
return id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment