ether-code 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/ether.js +1 -1
- package/generators/js-generator.js +14 -11
- package/package.json +1 -1
package/cli/ether.js
CHANGED
|
@@ -1086,16 +1086,17 @@ class JSGenerator {
|
|
|
1086
1086
|
const name = node.name || (node.id ? (node.id.name || node.id) : '')
|
|
1087
1087
|
const params = (node.params || []).map(p => this.generateParam(p)).join(', ')
|
|
1088
1088
|
|
|
1089
|
-
let body = ''
|
|
1090
1089
|
const savedOutput = this.output
|
|
1090
|
+
const baseIndent = this.indent
|
|
1091
1091
|
this.output = ''
|
|
1092
|
-
this.indent
|
|
1092
|
+
this.indent = baseIndent + 1
|
|
1093
1093
|
this.generateNode(node.body)
|
|
1094
|
-
this.
|
|
1095
|
-
body = this.output.trim()
|
|
1094
|
+
const body = this.output.trimEnd()
|
|
1096
1095
|
this.output = savedOutput
|
|
1096
|
+
this.indent = baseIndent
|
|
1097
1097
|
|
|
1098
|
-
|
|
1098
|
+
const closingIndent = ' '.repeat(baseIndent)
|
|
1099
|
+
return `${async}function${generator} ${name}(${params}) {\n${body}\n${closingIndent}}`
|
|
1099
1100
|
}
|
|
1100
1101
|
|
|
1101
1102
|
generateParam(param) {
|
|
@@ -1670,15 +1671,17 @@ class JSGenerator {
|
|
|
1670
1671
|
: `(${params})`
|
|
1671
1672
|
|
|
1672
1673
|
if (node.body?.type === 'BlockStatement') {
|
|
1673
|
-
let body = ''
|
|
1674
1674
|
const savedOutput = this.output
|
|
1675
|
+
const baseIndent = this.indent
|
|
1675
1676
|
this.output = ''
|
|
1676
|
-
this.indent
|
|
1677
|
+
this.indent = baseIndent + 1
|
|
1677
1678
|
this.generateNode(node.body)
|
|
1678
|
-
this.
|
|
1679
|
-
body = this.output.trim()
|
|
1679
|
+
const body = this.output.trimEnd()
|
|
1680
1680
|
this.output = savedOutput
|
|
1681
|
-
|
|
1681
|
+
this.indent = baseIndent
|
|
1682
|
+
|
|
1683
|
+
const closingIndent = ' '.repeat(baseIndent)
|
|
1684
|
+
return `${async}${paramsStr} => {\n${body}\n${closingIndent}}`
|
|
1682
1685
|
} else {
|
|
1683
1686
|
const body = this.generateNode(node.body)
|
|
1684
1687
|
return `${async}${paramsStr} => ${body}`
|
|
@@ -1742,7 +1745,7 @@ class JSGenerator {
|
|
|
1742
1745
|
const left = this.generateNode(node.left)
|
|
1743
1746
|
const right = this.generateNode(node.right)
|
|
1744
1747
|
const op = this.translateOperator(node.operator)
|
|
1745
|
-
return
|
|
1748
|
+
return `${left} ${op} ${right}`
|
|
1746
1749
|
}
|
|
1747
1750
|
|
|
1748
1751
|
generateUnaryExpression(node) {
|