Compare commits

...

3 Commits

Author SHA1 Message Date
Mohammad Mahdi Robatjazi
8019a8df27
Merge f5992ec218292e7382382433e848c6b753964c9a into 8c975a4f0d22ef8828142729febce4696301a81a 2025-06-28 15:38:20 +08:00
Mohammad Mahdi Robatjazi
f5992ec218
Merge branch 'main' into refactor/getUID-performance 2025-01-28 20:26:20 +03:30
Mohammad
a1339d0d2d refactor(getUID): improve performance and simplify logic 2025-01-17 22:33:01 +03:30

View File

@ -5,7 +5,6 @@
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
const MAX_UID = 1_000_000
const MILLISECONDS_MULTIPLIER = 1000 const MILLISECONDS_MULTIPLIER = 1000
const TRANSITION_END = 'transitionend' const TRANSITION_END = 'transitionend'
@ -36,9 +35,10 @@ const toType = object => {
* Public Util API * Public Util API
*/ */
let idCount = 0
const getUID = prefix => { const getUID = prefix => {
do { do {
prefix += Math.floor(Math.random() * MAX_UID) prefix += idCount++
} while (document.getElementById(prefix)) } while (document.getElementById(prefix))
return prefix return prefix