Last active
October 28, 2019 13:58
-
-
Save andrew8088/ee33150326aacb02763af3326f1f08d4 to your computer and use it in GitHub Desktop.
Generate Request Id
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 now = () => { | |
const [sec, nano] = process.hrtime(); | |
return sec * 1e9 + nano; | |
}; | |
const rand = () => Math.floor(Math.random() * 1e16); | |
const getRequestId = () => | |
(now() + rand()) | |
.toString(16) | |
.substr(0, 12) | |
.toUpperCase(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will generate IDs like this: