UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

73 lines (63 loc) 1.54 kB
/** * Defines how to serialize and deserialize an instance of a given class */ export class BinaryClassSerializationAdapter { /** * Class that this adapter handles * @protected * @type {Class} */ klass = null; /** * Format version number, used to check for format changes and data compatibility * Increment the number if you change the adapter to indicate the change in format * See {@link BinaryClassUpgrader} for details on how to handle support for outdated format versions * @protected * @type {number} */ version = 0; /** * @template T * @returns {Class<T>} */ getClass() { return this.klass; } /** * * @returns {number} */ getVersion() { return this.version; } initialize(...args) { //override as needed } /** * Handle any necessary resource cleanup. * Invoked externally as part of the serialization lifecycle */ finalize() { //override as need } /** * @param {BinaryBuffer} buffer * @param value */ serialize(buffer, value) { //override as necessary } /** * * @param {BinaryBuffer} buffer * @param value */ deserialize(buffer, value) { //override as necessary } } /** * @readonly * @type {boolean} */ BinaryClassSerializationAdapter.prototype.isBinaryClassSerializationAdapter = true;