New LinearColorEntity, string serialization fixed

This commit is contained in:
barsdeveloper
2022-05-11 21:01:54 +02:00
parent 3c643f0c6a
commit e416591784
20 changed files with 707 additions and 125 deletions

View File

@@ -2,14 +2,30 @@
import GeneralSerializer from "./GeneralSerializer"
/**
* @typedef {import("../entity/IEntity").default} IEntity
*/
/**
* @template {IEntity} T
*/
export default class ToStringSerializer extends GeneralSerializer {
/**
* @param {new () => T} entityType
*/
constructor(entityType) {
super(undefined, entityType)
}
write(object) {
let result = object.toString()
/**
* @param {T} object
* @param {Boolean} insideString
*/
write(object, insideString) {
let result = insideString || object.isShownAsString()
? `"${object.toString().replaceAll('"', '\\"')}"`
: object.toString()
return result
}
}