about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util/ready.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/flavours/glitch/util/ready.js')
-rw-r--r--app/javascript/flavours/glitch/util/ready.js32
1 files changed, 0 insertions, 32 deletions
diff --git a/app/javascript/flavours/glitch/util/ready.js b/app/javascript/flavours/glitch/util/ready.js
deleted file mode 100644
index e769cc756..000000000
--- a/app/javascript/flavours/glitch/util/ready.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// @ts-check
-
-/**
- * @param {(() => void) | (() => Promise<void>)} callback
- * @returns {Promise<void>}
- */
-export default function ready(callback) {
-  return new Promise((resolve, reject) => {
-    function loaded() {
-      let result;
-      try {
-        result = callback();
-      } catch (err) {
-        reject(err);
-
-        return;
-      }
-
-      if (typeof result?.then === 'function') {
-        result.then(resolve).catch(reject);
-      } else {
-        resolve();
-      }
-    }
-
-    if (['interactive', 'complete'].includes(document.readyState)) {
-      loaded();
-    } else {
-      document.addEventListener('DOMContentLoaded', loaded);
-    }
-  });
-}