| | |
| | | /** @typedef {EXPECTED_FUNCTION} CacheAssoc */ |
| | | |
| | | /** |
| | | * Defines the shared type used by this module. |
| | | * @template T |
| | | * @typedef {WeakMap<CacheAssoc, ObjectStructure<T>>} |
| | | */ |
| | | const cache = new WeakMap(); |
| | | |
| | | /** |
| | | * Represents ObjectStructure. |
| | | * @template T |
| | | */ |
| | | class ObjectStructure { |
| | | constructor() { |
| | | /** @type {undefined | keyof T[]} */ |
| | | this.keys = undefined; |
| | | /** @type {undefined | Map<keyof T, ObjectStructure<T>>} */ |
| | | this.children = undefined; |
| | | } |
| | | |
| | | /** |
| | | * Returns keys. |
| | | * @param {keyof T[]} keys keys |
| | | * @returns {keyof T[]} keys |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns object structure. |
| | | * @param {keyof T} key key |
| | | * @returns {ObjectStructure<T>} object structure |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns keys. |
| | | * @template T |
| | | * @param {(keyof T)[]} keys keys |
| | | * @param {CacheAssoc} cacheAssoc cache assoc fn |
| | |
| | | |
| | | class PlainObjectSerializer { |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @template {object} T |
| | | * @param {T} obj plain object |
| | | * @param {ObjectSerializerContext} context context |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @template {object} T |
| | | * @param {ObjectDeserializerContext} context context |
| | | * @returns {T} plain object |