Skip to content

Commit

Permalink
refactor(getUID): improve performance and simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mmr-dev2008 committed Jan 17, 2025
1 parent 5210c9b commit a1339d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* --------------------------------------------------------------------------
*/

const MAX_UID = 1_000_000
const MILLISECONDS_MULTIPLIER = 1000
const TRANSITION_END = 'transitionend'

Expand Down Expand Up @@ -36,9 +35,10 @@ const toType = object => {
* Public Util API
*/

let idCount = 0
const getUID = prefix => {
do {
prefix += Math.floor(Math.random() * MAX_UID)
prefix += idCount++
} while (document.getElementById(prefix))

return prefix
Expand Down

0 comments on commit a1339d0

Please # to comment.