add vocabulary to subjects

This commit is contained in:
polv committed 2022-04-28 12:59:34 +07:00
1 parent a2e6e66bcf
commit 92c1de3d1f
2 files changed
+90 -43

No files matched your search

+4 -2
View File
@@ -9,14 +9,16 @@ interface ILevelMap {
};
}
async function makeWaniKaniKanjiLevels(opts: { cache?: boolean } = {}) {
async function makeWaniKaniKanjiLevels(
opts: { cache?: boolean; force?: boolean } = {},
) {
const FILENAME = 'cache/wanikani-kanji.yaml';
if (opts.cache && existsSync(FILENAME)) {
return yaml.load(readFileSync(FILENAME, 'utf-8')) as ILevelMap;
}
const wkKanji = await new WaniKani()
.subjects()
.subjects({ force: !!opts.force })
.then((vs) => vs.filter((v) => v.object === 'kanji') as IKanji[]);
const levelMap: ILevelMap = {};