From 51546e14240a7f6e1e4ddeb46e5a8eb0ec036de4 Mon Sep 17 00:00:00 2001 From: Yan-Fa Li Date: Wed, 6 Nov 2024 13:53:39 -0800 Subject: [PATCH] chore: simplify conditional using ? --- src/store/keycodes.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/store/keycodes.js b/src/store/keycodes.js index ff76edc811..45b9d14517 100644 --- a/src/store/keycodes.js +++ b/src/store/keycodes.js @@ -18,10 +18,7 @@ const keycodePickerTabLayout = { function getOSKeyboardLayout() { let osKeyboardLayout = store.getters['app/osKeyboardLayout']; - if ( - isUndefined(osKeyboardLayout) || - !keymapExtras[osKeyboardLayout] - ) { + if (isUndefined(osKeyboardLayout) || !keymapExtras[osKeyboardLayout]) { const fallbackOSKeyboardLayout = 'keymap_us'; console.log( `The stored OS keyboard layout value (${osKeyboardLayout}) is not a valid value! Falling back to '${fallbackOSKeyboardLayout}'.` @@ -38,10 +35,7 @@ function isANSI() { function toLocaleKeycode(keycodeLUT, keycodeObject) { console.assert(!isUndefined(keycodeLUT)); - if ( - !keycodeObject.name || - !keycodeObject.code - ) { + if (!keycodeObject.name || !keycodeObject.code) { // Not an object describing a keyboard key; return as is return keycodeObject; } @@ -75,8 +69,8 @@ function countMatches(filter, collection) { if (!isUndefined(code)) { if ( code.includes(filter) || - (name && name.toUpperCase().includes(filter)) || - (title && title.toUpperCase().includes(filter)) + name?.toUpperCase().includes(filter) || + title?.toUpperCase().includes(filter) ) { matchCount += 1; }