Skip to content

Instantly share code, notes, and snippets.

@BrianHung
Last active December 15, 2022 07:47
Show Gist options
  • Select an option

  • Save BrianHung/134988dd6749403d82ddd96da0a46c60 to your computer and use it in GitHub Desktop.

Select an option

Save BrianHung/134988dd6749403d82ddd96da0a46c60 to your computer and use it in GitHub Desktop.
function uniqueId(a = ''): string {
return a
? /* eslint-disable no-bitwise */
((Number(a) ^ (Math.random() * 16)) >> (Number(a) / 4)).toString(16)
: `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, uniqueId)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment