Skip to content

Commit 1ecbc7c

Browse files
committed
refactor
1 parent be14c67 commit 1ecbc7c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/translator/predicate.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ArrayResult } from "../array_result.ts";
2-
import { nullableAsArray } from "../misc.ts";
2+
import { nullableAsArray, throwError } from "../misc.ts";
33
import * as TokiPona from "../parser/ast.ts";
44
import { AdjectiveWithInWay } from "./adjective.ts";
55
import * as English from "./ast.ts";
@@ -116,14 +116,11 @@ function associatedPredicate(
116116
preposition: ReadonlyArray<English.Preposition>,
117117
): ArrayResult<PartialCompoundVerb> {
118118
return ArrayResult.from(() => {
119-
let verbObject: ArrayResult<PartialCompoundVerb>;
120-
if (object == null) {
121-
verbObject = new ArrayResult([phraseAsVerb(predicate)]);
122-
} else if (object.type === "noun") {
123-
verbObject = predicateVerb(predicate, object.noun);
124-
} else {
125-
throw new UntranslatableError(object.type, "object");
126-
}
119+
const verbObject = object == null
120+
? new ArrayResult([phraseAsVerb(predicate)])
121+
: object.type === "noun"
122+
? predicateVerb(predicate, object.noun)
123+
: throwError(new UntranslatableError(object.type, "object"));
127124
return verbObject.map((verbObject) => ({
128125
...verbObject,
129126
preposition: [...verbObject.preposition, ...preposition],

0 commit comments

Comments
 (0)