mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
35 lines
871 B
JavaScript
Executable File
35 lines
871 B
JavaScript
Executable File
import Serializer from "./Serializer.js"
|
|
|
|
/**
|
|
* @typedef {import("../entity/IEntity").AnyValue} AnyValue
|
|
* @typedef {import("../entity/IEntity").AnyValueConstructor<*>} AnyValueConstructor
|
|
*/
|
|
|
|
/**
|
|
* @template {AnyValue} T
|
|
* @extends {Serializer<T>}
|
|
*/
|
|
export default class CustomSerializer extends Serializer {
|
|
|
|
#objectWriter
|
|
|
|
/**
|
|
* @param {(v: T, insideString: Boolean) => String} objectWriter
|
|
* @param {AnyValueConstructor} entityType
|
|
*/
|
|
constructor(objectWriter, entityType) {
|
|
super(entityType)
|
|
this.#objectWriter = objectWriter
|
|
}
|
|
|
|
/**
|
|
* @param {T} entity
|
|
* @param {Boolean} insideString
|
|
* @returns {String}
|
|
*/
|
|
doWrite(entity, insideString, indentation = "") {
|
|
let result = this.#objectWriter(entity, insideString)
|
|
return result
|
|
}
|
|
}
|