Byte pin type

This commit is contained in:
barsdeveloper
2022-12-29 10:50:41 +01:00
parent 5036866b33
commit 0e7b61d701
14 changed files with 169 additions and 34 deletions

24
js/entity/ByteEntity.js Executable file
View File

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