Skip to content

Commit 140070c

Browse files
committed
refactor
1 parent 42d7e92 commit 140070c

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/translator/clause.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ function oClause(clause: TokiPona.Clause & { type: "o clause" }) {
154154
verb(predicate, subjectPerspective, subjectQuantity)
155155
.map((verb) => iWish(subject, verb)),
156156
IterableResult.from(() => {
157-
const takeNegative = true;
158157
return verb(
159-
addModalToAll("should", predicate, takeNegative),
158+
addModalToAll({
159+
modal: "should",
160+
verb: predicate,
161+
takeNegative: true,
162+
}),
160163
subjectPerspective,
161164
subjectQuantity,
162165
);

src/translator/verb.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ function condenseVerb(present: string, past: string) {
5050
return [condense(first, second), ...rest].join(" ");
5151
}
5252
function addModal(
53-
modal: string,
54-
verb: PartialVerb,
55-
takeNegative: boolean,
53+
options: Readonly<{
54+
modal: string;
55+
verb: PartialVerb;
56+
takeNegative: boolean;
57+
}>,
5658
) {
59+
const { modal, verb, takeNegative } = options;
5760
if (verb.modal == null) {
5861
const newRest = nullableAsArray(verb.first)
5962
.map((first) => {
@@ -89,18 +92,21 @@ function addModal(
8992
}
9093
}
9194
export function addModalToAll(
92-
modal: string,
93-
verb: PartialCompoundVerb,
94-
takeNegative: boolean,
95+
options: Readonly<{
96+
modal: string;
97+
verb: PartialCompoundVerb;
98+
takeNegative: boolean;
99+
}>,
95100
): PartialCompoundVerb {
101+
const { modal, verb, takeNegative } = options;
96102
switch (verb.type) {
97103
case "simple":
98-
return { ...addModal(modal, verb, takeNegative), type: "simple" };
104+
return { ...addModal({ modal, verb, takeNegative }), type: "simple" };
99105
case "compound":
100106
return {
101107
...verb,
102108
verbs: verb.verbs.map((verb) =>
103-
addModalToAll(modal, verb, takeNegative)
109+
addModalToAll({ modal, verb, takeNegative })
104110
),
105111
};
106112
}

0 commit comments

Comments
 (0)