From 56718fd2063f940f2d29000d24e5c42d1a804b4c Mon Sep 17 00:00:00 2001 From: fredcw Date: Thu, 28 Sep 2023 22:33:14 +0100 Subject: [PATCH] state.js: replace polyfills with js natives.. (#11873) This is a follow on from commit github.com/linuxmint/cinnamon/commit/e4b39d33273cdf5f83f786063a68de5e437db18b --- js/misc/state.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/js/misc/state.js b/js/misc/state.js index aeb4ed6aaa..3c50a57faa 100644 --- a/js/misc/state.js +++ b/js/misc/state.js @@ -1,4 +1,3 @@ -const {find, filter} = imports.misc.util; function intersect(array1, array2, difference = false) { let result = []; @@ -228,7 +227,7 @@ function createStore(state = {}, listeners = [], connections = 0) { function trigger() { const [key, ...args] = Array.from(arguments); - let matchedListeners = filter(listeners, function(listener) { + let matchedListeners = listeners.filter(function(listener) { return listener.keys.indexOf(key) > -1 && listener.callback; }); if (matchedListeners.length === 0) { @@ -247,7 +246,7 @@ function createStore(state = {}, listeners = [], connections = 0) { let listener; if (callback) { - listener = find(listeners, function(listener) { + listener = listeners.find(function(listener) { return listener.callback === callback; }); } @@ -276,7 +275,7 @@ function createStore(state = {}, listeners = [], connections = 0) { } function disconnectByKey(key) { - let listener = filter(listeners, function(listener) { + let listener = listeners.filter(function(listener) { return listener.keys.indexOf(key) > -1; }); let listenerIndex = listeners.indexOf(listener);