Skip to content

Commit d443ffb

Browse files
author
yihao03
committed
Refactor async execution in fancyName function and improve error handling in Promise.all
1 parent ba88b63 commit d443ffb

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

i18n/index.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@ import PathGenerator from "./controllers/path.ts";
33
import translate from "./controllers/recurTranslate.ts";
44

55
export default async function fancyName(path: string) {
6-
const startTime = new Date().getTime();
76

87
const fullPath = PathGenerator(path);
9-
console.log("Translating: " + fullPath);
108
await translate("Chinese", fullPath);
11-
12-
const elapsed = new Date().getTime() - startTime;
13-
console.log(fullPath + " took " + elapsed / 1000.0 + " seconds");
149
}
1510

16-
17-
18-
await Promise.all([
19-
fancyName("2")
20-
// fancyName("1.1"),
21-
// fancyName("1.1.2"),
22-
// fancyName("1.1.3"),
23-
// fancyName("1.1.4"),
24-
// fancyName("1.1.5"),
25-
// fancyName("1.1.6"),
26-
// fancyName("1.1.7"),
27-
// fancyName("1.1.8"),
28-
// translate("Chinese", "1"),
29-
]);
11+
(async () => {
12+
try {
13+
await Promise.all([
14+
// fancyName("2")
15+
// fancyName("1.1"),
16+
// fancyName("1.1.2"),
17+
// fancyName("1.1.3"),
18+
// fancyName("1.1.4"),
19+
// fancyName("1.1.5"),
20+
fancyName("1.1.6"),
21+
// fancyName("1.1.7")
22+
// fancyName("1.1.8"),
23+
// translate("Chinese", "1"),
24+
]);
25+
} catch (e) {
26+
console.error(e);
27+
}
28+
})();

0 commit comments

Comments
 (0)