Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Transpiled map iterator to target es5
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 20, 2017
1 parent 6c683d7 commit 3bfcb6e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/formatStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const formatStats: FormatStats = Object.assign(
while (description_file !== undefined) {
const data: Descriptions = description_file.data;

lines.push(...formatWithFinder(untranslated, ({id}) => data[id]));
lines.push(...formatWithFinder(untranslated, ({ id }) => data[id]));
lines.push(
...formatWithFinder(untranslated, ({ id }) => findDescription(id, data))
);
Expand Down Expand Up @@ -118,8 +118,13 @@ function formatWithFinder(
find: (stat: Stat) => Description | undefined
): string[] {
const lines: string[] = [];
const translated: Set<string> = new Set();

for (const [stat_id, stat] of Array.from(stats.entries())) {
if (translated.has(stat_id)) {
continue;
}

for (const [stat_id, stat] of stats) {
const description = find(stat);

if (description !== undefined) {
Expand All @@ -129,7 +134,10 @@ function formatWithFinder(
throw new Error(`matching translation not found for '${stat.id}'`);
} else {
// mark as translated
description.stats.forEach(translated_id => stats.delete(translated_id));
description.stats.forEach(translated_id => {
stats.delete(translated_id);
translated.add(translated_id);
});

if (translation === NO_DESCRIPTION) {
lines.push(`${stat_id} (hidden)`);
Expand Down

0 comments on commit 3bfcb6e

Please sign in to comment.