esrap 1.4.1 → 1.4.3
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/package.json +1 -1
- package/src/handlers.js +19 -7
package/package.json
CHANGED
package/src/handlers.js
CHANGED
|
@@ -129,6 +129,8 @@ function quote(string, char) {
|
|
|
129
129
|
out += '\\' + c;
|
|
130
130
|
} else if (c === '\n') {
|
|
131
131
|
out += '\\n';
|
|
132
|
+
} else if (c === '\r') {
|
|
133
|
+
out += '\\r';
|
|
132
134
|
} else {
|
|
133
135
|
out += c;
|
|
134
136
|
}
|
|
@@ -656,16 +658,26 @@ const shared = {
|
|
|
656
658
|
* @param {State} state
|
|
657
659
|
*/
|
|
658
660
|
'BlockStatement|ClassBody': (node, state) => {
|
|
659
|
-
if (node.
|
|
660
|
-
|
|
661
|
-
|
|
661
|
+
if (node.loc) {
|
|
662
|
+
const { line, column } = node.loc.start;
|
|
663
|
+
state.commands.push(l(line, column), '{', l(line, column + 1));
|
|
664
|
+
} else {
|
|
665
|
+
state.commands.push('{');
|
|
662
666
|
}
|
|
663
667
|
|
|
664
|
-
|
|
668
|
+
if (node.body.length > 0) {
|
|
669
|
+
state.multiline = true;
|
|
670
|
+
state.commands.push(indent, newline);
|
|
671
|
+
handle_body(node.body, state);
|
|
672
|
+
state.commands.push(dedent, newline);
|
|
673
|
+
}
|
|
665
674
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
675
|
+
if (node.loc) {
|
|
676
|
+
const { line, column } = node.loc.end;
|
|
677
|
+
state.commands.push(l(line, column - 1), '}', l(line, column));
|
|
678
|
+
} else {
|
|
679
|
+
state.commands.push('}');
|
|
680
|
+
}
|
|
669
681
|
},
|
|
670
682
|
|
|
671
683
|
/**
|