Entities cleanup, Primitive concept introduced

This commit is contained in:
barsdeveloper
2021-10-25 15:49:09 +02:00
parent bee57a1402
commit 92828705d3
21 changed files with 292 additions and 284 deletions

View File

@@ -1,37 +0,0 @@
import Entity from "./Entity";
export default class GuidEntity extends Entity {
static attributes = {
value: String
}
static generateGuid(random) {
let values = new Uint32Array(4);
if (random === true) {
crypto.getRandomValues(values)
}
let result = ""
values.forEach(n => {
result += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
})
return result
}
constructor(guid) {
if (guid?.constructor === String) {
guid = {
value: guid
}
} else if (guid?.constructor === Boolean) {
guid = {
value: GuidEntity.generateGuid(guid == true)
}
}
super(guid)
}
getAttributes() {
return GuidEntity.attributes
}
}