Skip to content

Instantly share code, notes, and snippets.

@South-Paw
Last active December 12, 2020 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save South-Paw/ec0c20a8a848d3727368ad765f6ffec6 to your computer and use it in GitHub Desktop.
Save South-Paw/ec0c20a8a848d3727368ad765f6ffec6 to your computer and use it in GitHub Desktop.
MongoDB Object ID generator TypeScript
export const uuid = () =>
((new Date().getTime() / 1000) | 0).toString(16) +
'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => ((Math.random() * 16) | 0).toString(16)).toLowerCase();
@South-Paw
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment