Created
September 5, 2019 13:46
-
-
Save tokdaniel/85d658bb84df2a60d427bddf8fc4a9b4 to your computer and use it in GitHub Desktop.
Relatively safe ID generator, fixed length option
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
const ID = () => (Date.now() + Math.random().toString(36) | |
.substr(2, 9)) | |
.split('') | |
.sort(() => (0.5 > Math.random() ? -1 : 1)) | |
.join(''); | |
const createFixedLengthID = (length) => ID().padStart(length, ID()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment