From d3879c07b1b2140bd19433ae06855894228bd90f Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 11 Oct 2022 10:41:15 +0200 Subject: Rename flavours/glitch/util into flavours/glitch/utils --- app/javascript/flavours/glitch/util/ready.js | 32 ---------------------------- 1 file changed, 32 deletions(-) delete mode 100644 app/javascript/flavours/glitch/util/ready.js (limited to 'app/javascript/flavours/glitch/util/ready.js') 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)} callback - * @returns {Promise} - */ -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); - } - }); -} -- cgit