Skip to content

Commit aa2259c

Browse files
committed
small refactor
1 parent 190ab1d commit aa2259c

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

src/parser/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export const CLAUSE_RULE: ReadonlyArray<(clause: Clause) => boolean> = [
288288
phrase.emphasis == null
289289
) {
290290
const { word } = phrase.headWord;
291-
if (word === "mi" || word === "sina") {
291+
if (["mi", "sina"].includes(word)) {
292292
throw new UnrecognizedError(`"${word} li"`);
293293
}
294294
}

src/translator/sentence.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,32 @@ function interjection(clause: TokiPona.Clause): ArrayResult<English.Clause> {
6767
const { phrase } = clause.phrases;
6868
if (phrase.type === "default" && phrase.modifiers.length === 0) {
6969
const { headWord } = phrase;
70-
if (headWord.type === "default" || headWord.type === "reduplication") {
71-
return new ArrayResult(dictionary.get(headWord.word)!.definitions)
72-
.filterMap((definition) => {
73-
if (definition.type === "interjection") {
74-
switch (headWord.type) {
75-
case "default":
76-
return definition.interjection;
77-
case "reduplication":
78-
return repeatWithSpace(
79-
definition.interjection,
80-
headWord.count,
81-
);
70+
switch (headWord.type) {
71+
case "default":
72+
case "reduplication":
73+
return new ArrayResult(dictionary.get(headWord.word)!.definitions)
74+
.filterMap((definition) => {
75+
if (definition.type === "interjection") {
76+
switch (headWord.type) {
77+
case "default":
78+
return definition.interjection;
79+
case "reduplication":
80+
return repeatWithSpace(
81+
definition.interjection,
82+
headWord.count,
83+
);
84+
}
85+
} else {
86+
return null;
8287
}
83-
} else {
84-
return null;
85-
}
86-
})
87-
.map<English.Clause>((interjection) => ({
88-
type: "interjection",
89-
interjection: {
90-
word: interjection,
91-
emphasis: headWord.emphasis != null,
92-
},
93-
}));
88+
})
89+
.map<English.Clause>((interjection) => ({
90+
type: "interjection",
91+
interjection: {
92+
word: interjection,
93+
emphasis: headWord.emphasis != null,
94+
},
95+
}));
9496
}
9597
}
9698
}

0 commit comments

Comments
 (0)