diff options
Diffstat (limited to 'ext/js/dictionary/dictionary-importer.js')
-rw-r--r-- | ext/js/dictionary/dictionary-importer.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/ext/js/dictionary/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js index a9726aaf..067c8a3a 100644 --- a/ext/js/dictionary/dictionary-importer.js +++ b/ext/js/dictionary/dictionary-importer.js @@ -115,13 +115,13 @@ export class DictionaryImporter { // Files /** @type {import('dictionary-importer').QueryDetails} */ - const queryDetails = new Map([ + const queryDetails = [ ['termFiles', /^term_bank_(\d+)\.json$/], ['termMetaFiles', /^term_meta_bank_(\d+)\.json$/], ['kanjiFiles', /^kanji_bank_(\d+)\.json$/], ['kanjiMetaFiles', /^kanji_meta_bank_(\d+)\.json$/], ['tagFiles', /^tag_bank_(\d+)\.json$/] - ]); + ]; const {termFiles, termMetaFiles, kanjiFiles, kanjiMetaFiles, tagFiles} = Object.fromEntries(this._getArchiveFiles(fileMap, queryDetails)); // Load data @@ -692,16 +692,18 @@ export class DictionaryImporter { _getArchiveFiles(fileMap, queryDetails) { /** @type {import('dictionary-importer').QueryResult} */ const results = new Map(); - for (const [name, value] of fileMap.entries()) { - for (const [fileType, fileNameFormat] of queryDetails.entries()) { - let entries = results.get(fileType); - if (typeof entries === 'undefined') { - entries = []; - results.set(fileType, entries); - } - if (fileNameFormat.test(name)) { - entries.push(value); + for (const [fileType] of queryDetails) { + results.set(fileType, []); + } + + for (const [fileName, fileEntry] of fileMap.entries()) { + for (const [fileType, fileNameFormat] of queryDetails) { + if (!fileNameFormat.test(fileName)) { continue; } + const entries = results.get(fileType); + + if (typeof entries !== 'undefined') { + entries.push(fileEntry); break; } } |