Tests for various entity classes and update entity class implementations

This commit is contained in:
barsdeveloper
2024-06-03 00:11:30 +02:00
parent 5314228b33
commit 8fed17b20f
11 changed files with 309 additions and 210 deletions

View File

@@ -16,6 +16,7 @@ export default class IEntity {
static wrap = this.defaultWrapped
static attributeSeparator = ","
static keySeparator = "="
/** @type {(k: String) => String} */
static printKey = k => k
@@ -103,7 +104,6 @@ export default class IEntity {
*/
static asUniqueClass() {
if (this.name.length) {
// @ts-expect-error
return class extends this { }
}
return this
@@ -281,9 +281,9 @@ export default class IEntity {
if (Self.quoted) {
keyValue = `"${keyValue}"`
}
result += Self.attributeSeparator.includes("\n") ? indentation : ""
result += (Self.attributeSeparator.includes("\n") ? indentation : "") + keyValue + Self.keySeparator
}
let serialization = value.toString(insideString, indentation, printKey)
let serialization = value?.toString(insideString, indentation, printKey)
if (Self.serialized) {
serialization = `"${serialization.replaceAll(/(?<=(?:[^\\]|^)(?:\\\\)*?)"/, '\\"')}"`
}