« get me outta code hell

optional data pre-cache - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/cacheable-object.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-06-29 00:02:17 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-06-29 00:02:17 -0300
commitcdee3e9d4f3a721fb6efd11f6bcac64d6d08a201 (patch)
tree2b1f4cd54c74d63948ed7881e74e25ebd1fc6d86 /src/data/cacheable-object.js
parent9db3ec35804bbe566d1d20401fecedc657434256 (diff)
optional data pre-cache
Diffstat (limited to 'src/data/cacheable-object.js')
-rw-r--r--src/data/cacheable-object.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index fe1817f..688d8a0 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -315,6 +315,30 @@ export default class CacheableObject {
     };
   }
 
+  static cacheAllExposedProperties(obj) {
+    if (!(obj instanceof CacheableObject)) {
+      console.warn('Not a CacheableObject:', obj);
+      return;
+    }
+
+    if (!obj.constructor.propertyDescriptors) {
+      console.warn('Missing property descriptors:', obj);
+      return;
+    }
+
+    for (const [property, descriptor] of Object.entries(
+      obj.constructor.propertyDescriptors
+    )) {
+      const {flags} = descriptor;
+
+      if (!flags.expose) {
+        continue;
+      }
+
+      obj[property];
+    }
+  }
+
   static DEBUG_SLOW_TRACK_INVALID_PROPERTIES = false;
   static _invalidAccesses = new Set();