09-23-2020 11:46 AM
Hi
I am using math.random() function of mapper component to generate unique guids. I am worried that after repetitive use of this function it will generate duplicate results. Is there any way i can be sure that it doesnt generate same guids. Is there any other efficient way of doing this. Please let me know.
Thanks
Yash
09-23-2020 01:29 PM
No. I’d just use a randomUUID. You’re extremely unlikely to get repeats. We use them all the time when we need unique values and I’m not aware of any issues related to repeats.
09-23-2020 01:37 PM
Actually, how about this?
(Date.now().getTime() + Math.randomUUID()).substr(0,36)
That will give you a value like 16008933027615cf16319-1480-4260-9c84. The time component changes every millisecond, plus a random component, and it’s the length you want.