Skip to content

Commit 56c7034

Browse files
committed
backend(svg-generator.ts): modified the generateLines function so it generates the lines at the same time with the Promise.all function
1 parent 6c9d99c commit 56c7034

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/svg/svg-generator.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ export default class SvgGenerator {
7070
};
7171

7272
private generateLines = async (): Promise<string> => {
73-
let res = "";
73+
const promises: Promise<string>[] = [];
7474

7575
for (const line of this.card.getLinesMap()) {
76-
res += await this.createLine(line[1], line[0]);
76+
promises.push(this.createLine(line[1], line[0]));
7777
}
7878

79-
return res;
79+
const resolved = await Promise.all(promises);
80+
81+
return resolved.reduce((res, line) => {
82+
return (res += line);
83+
}, "");
8084
};
8185

8286
private createLine = async (

0 commit comments

Comments
 (0)