mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
24 lines
546 B
JavaScript
Executable File
24 lines
546 B
JavaScript
Executable File
import P from "parsernostrum"
|
|
import IntegerEntity from "./IntegerEntity.js"
|
|
|
|
export default class ByteEntity extends IntegerEntity {
|
|
|
|
static grammar = this.createGrammar()
|
|
|
|
get value() {
|
|
return super.value
|
|
}
|
|
set value(value) {
|
|
value = Math.trunc(value)
|
|
if (value >= 0 && value < 1 << 8) {
|
|
super.value = value
|
|
}
|
|
}
|
|
|
|
/** @returns {P<ByteEntity>} */
|
|
createGrammar() {
|
|
// @ts-expect-error
|
|
return P.numberByte.map(v => new this(v))
|
|
}
|
|
}
|