Filterable attributes, Int64 entity

This commit is contained in:
barsdeveloper
2023-01-03 22:53:17 +01:00
parent f4ebfa488a
commit a16481194c
21 changed files with 401 additions and 214 deletions

View File

@@ -3,25 +3,18 @@ import IntegerEntity from "./IntegerEntity"
export default class ByteEntity extends IntegerEntity {
static attributes = {
value: 0,
...super.attributes,
value: {
...super.attributes.value,
predicate: v => v % 1 == 0 && v >= 0 && v < 1 << 8,
},
}
static {
this.cleanupAttributes(this.attributes)
}
/** @param {Object | Number | String} values */
constructor(values = 0) {
super(values)
const value = Math.round(this.value)
this.value = value >= 0 && value < 1 << 8 ? value : 0
}
valueOf() {
return this.value
}
toString() {
return this.value.toString()
}
}