aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/database.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-18 23:16:33 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-18 23:16:33 -0400
commit9364a7cb4ebec4f0ec2c1b51e305ab00a8131856 (patch)
treef872669c494e2a8e25a31943f5987b847e410ad3 /ext/bg/js/database.js
parent6743b785c9f75c0bc6e628360155bdaebdacaa62 (diff)
Create function for creating kanji data and meta
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r--ext/bg/js/database.js33
1 files changed, 17 insertions, 16 deletions
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,