mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:08:18 +08:00
* WIP * Fix type 1 * Missing types info * Some fixes * Several types refactoring and fixes * WIP * Fix grammar
25 lines
734 B
JavaScript
Executable File
25 lines
734 B
JavaScript
Executable File
import Serializer from "./Serializer.js"
|
|
import Utility from "../Utility.js"
|
|
|
|
/**
|
|
* @template {SimpleValueType<SimpleValue>} T
|
|
* @extends {Serializer<T>}
|
|
*/
|
|
export default class ToStringSerializer extends Serializer {
|
|
|
|
/** @param {T} entityType */
|
|
constructor(entityType) {
|
|
super(entityType)
|
|
}
|
|
|
|
/**
|
|
* @param {ConstructedType<T>} entity
|
|
* @param {Boolean} insideString
|
|
*/
|
|
doWrite(entity, insideString, indentation = "") {
|
|
return !insideString && entity.constructor === String
|
|
? `"${Utility.escapeString(entity.toString())}"` // String will have quotes if not inside a string already
|
|
: Utility.escapeString(entity.toString())
|
|
}
|
|
}
|