From bf687fecf8766a546f2d34e9800fc7653ea2635f Mon Sep 17 00:00:00 2001 From: leonid-shutov Date: Mon, 13 Jan 2025 18:28:26 +0100 Subject: [PATCH] make more compact --- lib/expressions.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/expressions.js b/lib/expressions.js index 6725699..27bafeb 100644 --- a/lib/expressions.js +++ b/lib/expressions.js @@ -71,16 +71,11 @@ class OperationExpression { toJavaScript() { let header = '('; - for (const identifier of this.identifiers) { - if (header.length > 1) { - header += ', '; - } + if (header.length > 1) header += ', '; header += identifier; } - header += ')'; - return `${header} => ${this.toExpression()}`; } } @@ -122,31 +117,23 @@ 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()};`, ); - return `${ifExpression} {${consequentExpressions.join(' ')}}`; }); - return ifExpressions.join(' '); } toJavaScript() { let header = '('; - for (const identifier of this.identifiers) { - if (header.length > 1) { - header += ', '; - } + if (header.length > 1) header += ', '; header += identifier; } - header += ')'; - return `${header} => {${this.toExpression()}}`; } }