I want to create a function in my NodeJS application which generates unique 18 digit numbers. What I'm expecting is to get unique 18 digit numbers like below:
73306495056092753667
I thought of using the below logic, by combining Date.now() with Math.random():
Date.now()+""+Math.floor(Math.random()*10000000)
But in cases where my function is called exactly at the same millisecond, and if in the same cases, Math.random() returns the same value, the above logic wont return unique ID's.
In NodeJS/Javascript, is there any module like UUID which generates globally unique numerical values? Or can anyone help me create an algorithm that will generate unique ID's?