Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created November 5, 2020 13:24
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 jonathantneal/282283243a7226caa19b78c2c18910f2 to your computer and use it in GitHub Desktop.
Save jonathantneal/282283243a7226caa19b78c2c18910f2 to your computer and use it in GitHub Desktop.
Create a unique identifier from an Object URL
/** Returns a unique identifier tied to the document in the window on which it was created. */
const createObjectUID = (): string => URL.createObjectURL(new Blob()).slice(-5)
/** Returns a prefixed, unique identifier tied to the document in the window on which it was created. */
const createPrefixedObjectUID = (prefix: string): string => prefix + URL.createObjectURL(new Blob()).slice(-5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment