|
|
@ -19,7 +19,7 @@ export class WaniKani { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
static getLevelLabel(level: number): ILevelLabel { |
|
|
|
static getLevelLabel(level: number): ILevelLabel | null { |
|
|
|
if (level < 11) { |
|
|
|
return { |
|
|
|
range: '01-10', |
|
|
@ -58,7 +58,7 @@ export class WaniKani { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
throw new Error(`invalid level: ${level}`); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
async subjects({ |
|
|
@ -303,9 +303,13 @@ export class WaniKani { |
|
|
|
>(); |
|
|
|
vocabularies.map((v) => { |
|
|
|
if (vocabMap.has(v.data.characters)) return; |
|
|
|
const level = v.data.level; |
|
|
|
const label = WaniKani.getLevelLabel(level); |
|
|
|
if (!label) throw new Error(`Invalid level: ${level}`); |
|
|
|
|
|
|
|
vocabMap.set(v.data.characters, { |
|
|
|
level: v.data.level, |
|
|
|
label: WaniKani.getLevelLabel(v.data.level), |
|
|
|
level, |
|
|
|
label, |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (!vocabMap.size) return; |
|
|
|