Skip to content

Commit

Permalink
simplify toJavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid-shutov committed Jan 23, 2025
1 parent 8235eb7 commit 9b3efcb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ class OperationExpression {
}

toJavaScript() {
let header = '(';
let header = '';
for (const identifier of this.identifiers) {
if (header.length > 1) header += ', ';
if (header) header += ', ';
header += identifier;
}
header += ')';
return `${header} => ${this.toExpression()}`;
return `(${header}) => ${this.toExpression()}`;
}
}

Expand Down Expand Up @@ -156,13 +155,12 @@ class ConditionExpression {
}

toJavaScript() {
let header = '(';
let header = '';
for (const identifier of this.identifiers) {
if (header.length > 1) header += ', ';
if (header) header += ', ';
header += identifier;
}
header += ')';
return `${header} => {${this.toExpression()}}`;
return `(${header}) => {${this.toExpression()}}`;
}
}

Expand Down

0 comments on commit 9b3efcb

Please sign in to comment.