asb_cloud_front/src/services/UidGenerator.ts

13 lines
536 B
TypeScript
Raw Normal View History

2021-05-28 12:04:50 +05:00
export function generateUUID():string {
let seed = (25869874412483
* new Date().getTime()
* (performance && performance.now && (performance.now()))) % 173395562924509
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
let random = Math.random()
seed = seed > 272
? seed = seed / 17
: seed = (seed * random * random * 557833831325167) % 173395562924509
random = Math.floor((random * seed) % 16)
return (c === 'x' ? random : (random & 0xB)).toString(16)
})
}