mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-20 21:07:37 +08:00
Started work on serialization, refactoring
This commit is contained in:
20
js/FGuid.js
Normal file
20
js/FGuid.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export default class FGuid {
|
||||
constructor(guid) {
|
||||
if (guid?.constructor?.name === 'String') {
|
||||
this.value = guid
|
||||
} else if (guid?.constructor?.name === 'FGuid') {
|
||||
this.value = guid.value
|
||||
} else {
|
||||
let random = new Uint32Array(4);
|
||||
crypto.getRandomValues(random)
|
||||
this.value = ""
|
||||
random.forEach(n => {
|
||||
this.value += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user