aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-25 22:10:49 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-25 22:15:49 -0500
commit0b5a26e64a3fecf4ab64e5a1b6a1b068cde695fe (patch)
tree60b99e1a79a12a904e29f9b57492ebcdf711c644
parentb391704f3db77f19aad7e1a4e61b515a18475024 (diff)
Update dictEnabledSet and dictConfigured to use for of
-rw-r--r--ext/bg/js/dictionary.js16
1 files changed, 5 insertions, 11 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 7b112381..ffeac80a 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -20,22 +20,16 @@
function dictEnabledSet(options) {
const enabledDictionaryMap = new Map();
- const optionsDictionaries = options.dictionaries;
- for (const title in optionsDictionaries) {
- if (!hasOwn(optionsDictionaries, title)) { continue; }
- const dictionary = optionsDictionaries[title];
- if (!dictionary.enabled) { continue; }
- enabledDictionaryMap.set(title, {
- priority: dictionary.priority || 0,
- allowSecondarySearches: !!dictionary.allowSecondarySearches
- });
+ for (const [title, {enabled, priority, allowSecondarySearches}] of Object.entries(options.dictionaries)) {
+ if (!enabled) { continue; }
+ enabledDictionaryMap.set(title, {priority, allowSecondarySearches});
}
return enabledDictionaryMap;
}
function dictConfigured(options) {
- for (const title in options.dictionaries) {
- if (options.dictionaries[title].enabled) {
+ for (const {enabled} of Object.values(options.dictionaries)) {
+ if (enabled) {
return true;
}
}