From 9364a7cb4ebec4f0ec2c1b51e305ab00a8131856 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 18 Oct 2019 23:16:33 -0400 Subject: Create function for creating kanji data and meta --- ext/bg/js/database.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'ext') diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 3a87a2cd..dfa4ea70 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -123,7 +123,7 @@ class Database { const results = []; const processRow = (row, index) => { if (titles.includes(row.dictionary)) { - results.push(Database.createTermMeta(row, index)); + results.push(Database.createMeta(row, index)); } }; @@ -148,15 +148,7 @@ class Database { const results = []; await this.db.kanji.where('character').equals(kanji).each(row => { if (titles.includes(row.dictionary)) { - results.push({ - character: row.character, - onyomi: dictFieldSplit(row.onyomi), - kunyomi: dictFieldSplit(row.kunyomi), - tags: dictFieldSplit(row.tags), - glossary: row.meanings, - stats: row.stats, - dictionary: row.dictionary - }); + results.push(Database.createKanji(row)); } }); @@ -169,11 +161,7 @@ class Database { const results = []; await this.db.kanjiMeta.where('character').equals(kanji).each(row => { if (titles.includes(row.dictionary)) { - results.push({ - mode: row.mode, - data: row.data, - dictionary: row.dictionary - }); + results.push(Database.createMeta(row)); } }); @@ -494,7 +482,20 @@ class Database { }; } - static createTermMeta(row, index) { + static createKanji(row, index) { + return { + index, + character: row.character, + onyomi: dictFieldSplit(row.onyomi), + kunyomi: dictFieldSplit(row.kunyomi), + tags: dictFieldSplit(row.tags), + glossary: row.meanings, + stats: row.stats, + dictionary: row.dictionary + }; + } + + static createMeta(row, index) { return { index, mode: row.mode, -- cgit v1.2.3