mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-14 00:54:48 +08:00
29 lines
648 B
JavaScript
Executable File
29 lines
648 B
JavaScript
Executable File
import P from "parsernostrum"
|
|
import IEntity from "./IEntity.js"
|
|
|
|
export default class BooleanEntity extends IEntity {
|
|
|
|
static grammar = P.regArray(/(true)|false/i)
|
|
.map(v => v[1] ? new this(true) : new this(false))
|
|
.label("BooleanEntity")
|
|
|
|
constructor(value = false) {
|
|
super()
|
|
this.value = value
|
|
}
|
|
|
|
valueOf() {
|
|
return this.value
|
|
}
|
|
|
|
toString(insideString = false) {
|
|
return this.value
|
|
? insideString
|
|
? "true"
|
|
: "True"
|
|
: insideString
|
|
? "false"
|
|
: "False"
|
|
}
|
|
}
|