From 9574ebe2128ae3a1b04935c13c3067e4c9a54e63 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 25 May 2023 09:02:38 +0300 Subject: [PATCH] Merge executeCallbacks and runCallback, simplify + optimize --- script.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/script.js b/script.js index 12f00cb1..77758571 100644 --- a/script.js +++ b/script.js @@ -37,17 +37,15 @@ function onOptionsChanged(callback) { optionsChangedCallbacks.push(callback); } -function runCallback(x, m) { - try { - x(m); - } catch (e) { - console.error("error running callback", x, ":", e); +function executeCallbacks(queue, arg) { + for (const callback of queue) { + try { + callback(arg); + } catch (e) { + console.error("error running callback", callback, ":", e); + } } } -function executeCallbacks(queue, m) { - queue.forEach(function(x) { - runCallback(x, m); - }); } var executedOnLoaded = false;