Use Map
This commit is contained in:
parent
a4bdffbd9d
commit
163211ade3
@ -506,28 +506,29 @@ class Translator {
|
|||||||
const names = Object.keys(items);
|
const names = Object.keys(items);
|
||||||
const tagMetaList = await this.getTagMetaList(names, title);
|
const tagMetaList = await this.getTagMetaList(names, title);
|
||||||
|
|
||||||
const stats = {};
|
const statsGroups = new Map();
|
||||||
for (let i = 0; i < names.length; ++i) {
|
for (let i = 0; i < names.length; ++i) {
|
||||||
const name = names[i];
|
const name = names[i];
|
||||||
const meta = tagMetaList[i];
|
const meta = tagMetaList[i];
|
||||||
if (meta === null) { continue; }
|
if (meta === null) { continue; }
|
||||||
|
|
||||||
const category = meta.category;
|
const category = meta.category;
|
||||||
const group = (
|
let group = statsGroups.get(category);
|
||||||
hasOwn(stats, category) ?
|
if (typeof group === 'undefined') {
|
||||||
stats[category] :
|
group = [];
|
||||||
(stats[category] = [])
|
statsGroups.set(category, group);
|
||||||
);
|
}
|
||||||
|
|
||||||
const stat = Object.assign({}, meta, {name, value: items[name]});
|
const stat = Object.assign({}, meta, {name, value: items[name]});
|
||||||
group.push(dictTagSanitize(stat));
|
group.push(dictTagSanitize(stat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stats = {};
|
||||||
const sortCompare = (a, b) => a.notes - b.notes;
|
const sortCompare = (a, b) => a.notes - b.notes;
|
||||||
for (const category in stats) {
|
for (const [category, group] of statsGroups.entries()) {
|
||||||
stats[category].sort(sortCompare);
|
group.sort(sortCompare);
|
||||||
|
stats[category] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user