Small refactoring

This commit is contained in:
barsdeveloper
2024-09-08 22:28:42 +02:00
parent 2114abef5c
commit 19ef3bd10e
43 changed files with 542 additions and 504 deletions

View File

@@ -7,27 +7,26 @@ export default class SimpleSerializationRotatorEntity extends RotatorEntity {
static attributeSeparator = ", "
static grammar = this.createGrammar()
/** @returns {P<SimpleSerializationRotatorEntity>} */
static createGrammar() {
return /** @type {P<SimpleSerializationRotatorEntity>} */(
P.alt(
P.regArray(new RegExp(
`(${NumberEntity.numberRegexSource})`
+ String.raw`\s*,\s*`
+ `(${NumberEntity.numberRegexSource})`
+ String.raw`\s*,\s*`
+ `(${NumberEntity.numberRegexSource})`
)).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({
R: new (RotatorEntity.attributes.R)(r, rPrecision?.length),
P: new (RotatorEntity.attributes.P)(p, pPrecision?.length),
Y: new (RotatorEntity.attributes.Y)(y, yPrecision?.length),
})),
RotatorEntity.grammar.map(v => new this({
R: v.R,
P: v.P,
Y: v.Y,
}))
).label("SimpleSerializationRotatorEntity")
)
return P.alt(
P.regArray(new RegExp(
`(${NumberEntity.numberRegexSource})`
+ String.raw`\s*,\s*`
+ `(${NumberEntity.numberRegexSource})`
+ String.raw`\s*,\s*`
+ `(${NumberEntity.numberRegexSource})`
)).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({
R: new (RotatorEntity.attributes.R)(r, rPrecision?.length),
P: new (RotatorEntity.attributes.P)(p, pPrecision?.length),
Y: new (RotatorEntity.attributes.Y)(y, yPrecision?.length),
})),
RotatorEntity.grammar.map(v => new this({
R: v.R,
P: v.P,
Y: v.Y,
}))
).label("SimpleSerializationRotatorEntity")
}
doSerialize() {