Skip to content

Commit d0b9ca0

Browse files
committed
impr(polyglot): Change signature of PolyglotWordset constructor.
(@IliyaZinoviev)
1 parent ca46e36 commit d0b9ca0

1 file changed

Lines changed: 20 additions & 28 deletions

File tree

frontend/src/ts/test/funbox/funbox-functions.ts

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,25 @@ export class PolyglotWordset implements IWordset {
156156
readonly langs: Language[];
157157
length: number;
158158

159-
constructor(
160-
wordsetMap: Map<Language, Wordset>,
161-
languageProperties: Map<Language, JSONData.LanguageProperties>,
162-
length: number,
163-
) {
164-
this.languageProperties = languageProperties;
165-
this.langs = Array.from(languageProperties.keys());
166-
this.wordsetMap = wordsetMap;
159+
constructor(languages: LanguageObject[]) {
160+
this.languageProperties = new Map<Language, JSONData.LanguageProperties>();
161+
this.wordsetMap = new Map<Language, Wordset>();
162+
this.length = 0;
163+
164+
for (const lang of languages) {
165+
const count = lang.words.length;
166+
this.length += count;
167+
168+
this.languageProperties.set(lang.name, {
169+
noLazyMode: lang.noLazyMode,
170+
ligatures: lang.ligatures,
171+
rightToLeft: lang.rightToLeft,
172+
additionalAccents: lang.additionalAccents,
173+
});
174+
175+
this.wordsetMap.set(lang.name, new Wordset(lang.words));
176+
}
177+
this.langs = Array.from(this.languageProperties.keys());
167178
this.length = length;
168179
this.resetIndexes();
169180
}
@@ -791,27 +802,8 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
791802
);
792803
throw new WordGenError("");
793804
}
794-
const languageProperties = new Map<
795-
Language,
796-
JSONData.LanguageProperties
797-
>();
798-
const wordsetMap = new Map<Language, Wordset>();
799-
let totalLength = 0;
800-
801-
for (const lang of languages) {
802-
const count = lang.words.length;
803-
totalLength += count;
804-
805-
languageProperties.set(lang.name, {
806-
noLazyMode: lang.noLazyMode,
807-
ligatures: lang.ligatures,
808-
rightToLeft: lang.rightToLeft,
809-
additionalAccents: lang.additionalAccents,
810-
});
811805

812-
wordsetMap.set(lang.name, new Wordset(lang.words));
813-
}
814-
return new PolyglotWordset(wordsetMap, languageProperties, totalLength);
806+
return new PolyglotWordset(languages);
815807
},
816808
},
817809
};

0 commit comments

Comments
 (0)