« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/cacheable-object.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index 71dc5bde..010d967a 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -374,6 +374,18 @@ export default class CacheableObject {
 
     return object.#propertyUpdateValues[key] ?? null;
   }
+
+  static clone(object) {
+    const newObject = Reflect.construct(object.constructor, []);
+
+    this.copyUpdateValuesOnto(object, newObject);
+
+    return newObject;
+  }
+
+  static copyUpdateValuesOnto(source, target) {
+    Object.assign(target, source.#propertyUpdateValues);
+  }
 }
 
 export class CacheableObjectPropertyValueError extends Error {