Files
ueblueprint/js/entity/StringEntity.js
barsdeveloper 8a2cd6c26e Fixing still
2024-07-17 21:38:10 +02:00

37 lines
910 B
JavaScript
Executable File

import P from "parsernostrum"
import Utility from "../Utility.js"
import IEntity from "./IEntity.js"
export default class StringEntity extends IEntity {
static grammar = /** @type {P<StringEntity>} */(
P.doubleQuotedString
.map(insideString => new this(Utility.unescapeString(insideString)))
.label("StringEntity")
)
/** @param {String} value */
constructor(value = "") {
super()
this.value = value
}
valueOf() {
return this.value
}
toString(
insideString = false,
indentation = "",
Self = this.Self(),
printKey = Self.printKey,
wrap = Self.wrap,
) {
let result = `"${Utility.escapeString(this.value)}"`
if (insideString) {
result = Utility.escapeString(result, false)
}
return result
}
}