From a1adacd3dc69230c0f22c9c01957356a7eb81402 Mon Sep 17 00:00:00 2001 From: leonid-shutov Date: Thu, 23 Jan 2025 23:10:53 +0100 Subject: [PATCH] simplify toExpression --- lib/expressions.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/expressions.js b/lib/expressions.js index 4776345..1c774ef 100644 --- a/lib/expressions.js +++ b/lib/expressions.js @@ -144,11 +144,12 @@ class ConditionExpression { toExpression() { const ifExpressions = this.clauses.map(({ condition, consequents }) => { const ifExpression = `if ${condition.toExpression()}`; - const consequentExpressions = consequents.map((consequent, i) => - i === consequents.length - 1 - ? `return ${consequent.toExpression()};` - : `${consequent.toExpression()};`, - ); + const consequentExpressions = consequents.map((consequent, i) => { + const consequentExpression = consequent.toExpression(); + return i === consequents.length - 1 + ? `return ${consequentExpression};` + : `${consequentExpression};`; + }); return `${ifExpression} {${consequentExpressions.join(' ')}}`; }); return ifExpressions.join(' ');