Skip to content

Commit

Permalink
build: improve config-generator performance (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix authored Nov 9, 2024
1 parent f187cbc commit 39dd438
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions scripts/config-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ export class ConfigGenerator {
private groupItemsBy(
rules: Rule[],
rulesGrouping: RulesGrouping
): Map<string, string[]> {
const map = new Map<string, string[]>();
): Set<string> {
const set = new Set<string>();
for (const item of rules) {
const key = item[rulesGrouping];
const group = map.get(key) || [];
group.push(item.value);
map.set(key, group);
set.add(item[rulesGrouping]);
}

return map;
return set;
}

public generateRulesCode() {
Expand All @@ -55,7 +52,7 @@ export class ConfigGenerator {

code += `import * as rules from "./rules-by-${this.rulesGrouping}.js";\n\n`;

for (const grouping of rulesMap.keys()) {
for (const grouping of rulesMap) {
exportGrouping.push(grouping);

code += `const ${camelCase(grouping)}Config = {\n`;
Expand Down

0 comments on commit 39dd438

Please sign in to comment.