Skip to content

Instantly share code, notes, and snippets.

@sccolbert
Created September 20, 2020 20:29
Show Gist options
  • Save sccolbert/6f54e37ebe1f1b260a17d81a85340a4f to your computer and use it in GitHub Desktop.
Save sccolbert/6f54e37ebe1f1b260a17d81a85340a4f to your computer and use it in GitHub Desktop.
Unique ID Generator
/**
* A function which takes no arguments and returns a unique string ID.
*
* Requirements:
* - The id must be unique for the current process only
* - The id should avoid hashing collisions when used as a key in a map
* - The function must not create global variables
* - The value of `Math.random()` cannot be assumed to be unique
* - The browser `Crypto` object may not be used
*/
const createUID = ...
// Example Usage
console.log(createUID())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment