mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-15 09:44:49 +08:00
WIP
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import P from "parsernostrum"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import IEntity from "./IEntity.js"
|
||||
|
||||
export default class NumberEntity extends IEntity {
|
||||
|
||||
static grammar = P.regArray(
|
||||
new RegExp(`(${P.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`)
|
||||
new RegExp(`(${Grammar.numberRegexSource})|(\\+?inf)|(-inf)`)
|
||||
).map(([_0, n, plusInf, minusInf]) => new this(
|
||||
n ? Number(n) : plusInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY
|
||||
))
|
||||
)).label("NumberEntity")
|
||||
|
||||
/** @type {Number} */
|
||||
#value
|
||||
@@ -31,6 +32,12 @@ export default class NumberEntity extends IEntity {
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.value === Number.POSITIVE_INFINITY) {
|
||||
return "+inf"
|
||||
}
|
||||
if (this.value === Number.NEGATIVE_INFINITY) {
|
||||
return "-inf"
|
||||
}
|
||||
return this.value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user