From 8daa894e2de65f27ed5fd2a8d449591969eacf08 Mon Sep 17 00:00:00 2001 From: Mikhail Bodrov Date: Fri, 14 Jun 2024 00:05:09 +0300 Subject: [PATCH] Simplify keymapSearch --- app/utils/funcs.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/app/utils/funcs.js b/app/utils/funcs.js index 12f0350b..0c5e085a 100644 --- a/app/utils/funcs.js +++ b/app/utils/funcs.js @@ -217,23 +217,11 @@ export const arrayIntersection = (array1, array2) => { }; export const keymapSearch = (keymap, keyedList) => { - let matchedWith = null; - - Object.keys(keymap).map((a) => { + return Object.keys(keymap).find((a) => { const item = keymap[a]; - if (matchedWith !== null) { - return null; - } - - if (arrayEquality(item, keyedList)) { - matchedWith = a; - } - - return true; + return arrayEquality(item, keyedList); }); - - return matchedWith; }; export const toggleFileExplorerDeviceType = (