mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-14 00:54:48 +08:00
45 lines
1.0 KiB
JavaScript
Executable File
45 lines
1.0 KiB
JavaScript
Executable File
import P from "parsernostrum"
|
|
import IEntity from "./IEntity.js"
|
|
|
|
export default class BooleanEntity extends IEntity {
|
|
|
|
static grammar = P.regArray(/(true)|(True)|(false)|(False)/)
|
|
.map(v => {
|
|
const result = (v[1] ?? v[2]) ? new this(true) : new this(false)
|
|
result.uppercase = (v[2] ?? v[4]) !== undefined
|
|
return result
|
|
})
|
|
.label("BooleanEntity")
|
|
|
|
#uppercase = true
|
|
get uppercase() {
|
|
return this.#uppercase
|
|
}
|
|
set uppercase(value) {
|
|
this.#uppercase = value
|
|
}
|
|
|
|
constructor(value = false) {
|
|
super()
|
|
this.value = value
|
|
}
|
|
|
|
valueOf() {
|
|
return this.value
|
|
}
|
|
|
|
toString(
|
|
insideString = false,
|
|
indentation = "",
|
|
printKey = this.Self().printKey,
|
|
) {
|
|
return this.value
|
|
? this.#uppercase
|
|
? "True"
|
|
: "true"
|
|
: this.#uppercase
|
|
? "False"
|
|
: "false"
|
|
}
|
|
}
|