Extra contents beyond WaniKani
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1015 B

import { readFileSync, writeFileSync } from 'fs';
import { ILevelMap } from '@/level';
import { WaniKani } from '@/wanikani';
import yaml from 'js-yaml';
export async function repairBeyond() {
const beyond = yaml.load(
readFileSync('cache/beyond.yaml', 'utf-8'),
) as Record<string, string>;
const levelMap: ILevelMap = {};
for (const [levelString, vs] of Object.entries(beyond)) {
const level = Number(levelString);
let category: string;
if (level < 71) {
category = '61-70: 無限 INFINITY';
} else if (level < 76) {
category = '71-75: 極端 BEYOND';
} else {
category = '76+: 熟達 MASTERY';
}
const catMap = levelMap[category] || {};
const ks = catMap[levelString] || [];
ks.push(...vs);
catMap[levelString] = ks;
levelMap[category] = catMap;
}
writeFileSync(
WaniKani.files.beyond,
yaml.dump(levelMap, {
sortKeys: true,
flowLevel: 2,
}),
);
}
if (require.main === module) {
repairBeyond();
}