Created
November 5, 2020 13:24
-
-
Save jonathantneal/282283243a7226caa19b78c2c18910f2 to your computer and use it in GitHub Desktop.
Create a unique identifier from an Object URL
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
/** 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) |
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
/** 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