Created
April 21, 2019 16:45
-
-
Save meftunca/50e9ec7c3caa7d7608521cdcbf681c2d to your computer and use it in GitHub Desktop.
JS uniqid generator
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 default (key = "key") => { | |
let ts = String(new Date().getTime()), | |
i = 0, | |
out = ""; | |
for (i = 0; i < ts.length; i += 2) { | |
out += Number(ts.substr(i, 2)).toString(36); | |
} | |
return key + out; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment