mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 18:54:44 +08:00
Naming
This commit is contained in:
25
js/Guid.js
Normal file
25
js/Guid.js
Normal file
@@ -0,0 +1,25 @@
|
||||
export default class Guid {
|
||||
static generateGuid() {
|
||||
let result = ""
|
||||
let random = new Uint32Array(4);
|
||||
crypto.getRandomValues(random)
|
||||
random.forEach(n => {
|
||||
this.result += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
if (guid?.constructor?.name === 'String') {
|
||||
this.value = guid
|
||||
} else if (guid?.constructor?.name === 'FGuid') {
|
||||
this.value = guid.value
|
||||
} else {
|
||||
this.value = Guid.generateGuid()
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user