@putout/printer 1.95.0 → 1.96.0

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/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.05.11, v1.96.0
2
+
3
+ feature:
4
+ - 9b7297f @putout/printer: improve support of LogicalExpression inside AwaitExpression
5
+
1
6
  2023.05.11, v1.95.0
2
7
 
3
8
  feature:
@@ -1,5 +1,33 @@
1
1
  'use strict';
2
2
 
3
+ const BinaryExpression = {
4
+ condition(path) {
5
+ return path.parentPath.isAwaitExpression();
6
+ },
7
+ before(path, {print}) {
8
+ print('(');
9
+ },
10
+ print(path, {write, traverse, maybe}) {
11
+ const left = path.get('left');
12
+ const right = path.get('right');
13
+ const isLeft = isLogical(path, left);
14
+ const isRight = isLogical(path, right);
15
+
16
+ maybe.write(isLeft, '(');
17
+ traverse(left);
18
+ maybe.write(isLeft, ')');
19
+ write.space();
20
+ write(path.node.operator);
21
+ write.space();
22
+ maybe.write(isRight, '(');
23
+ traverse(right);
24
+ maybe.write(isRight, ')');
25
+ },
26
+ after(path, {print}) {
27
+ print(')');
28
+ },
29
+ };
30
+
3
31
  module.exports.BinaryExpression = BinaryExpression;
4
32
  module.exports.LogicalExpression = BinaryExpression;
5
33
 
@@ -11,20 +39,3 @@ const isLogical = (main, path) => {
11
39
 
12
40
  return main.node.operator !== path.node.operator;
13
41
  };
14
-
15
- function BinaryExpression(path, {write, traverse, maybe}) {
16
- const left = path.get('left');
17
- const right = path.get('right');
18
- const isLeft = isLogical(path, left);
19
- const isRight = isLogical(path, right);
20
-
21
- maybe.write(isLeft, '(');
22
- traverse(left);
23
- maybe.write(isLeft, ')');
24
- write.space();
25
- write(path.node.operator);
26
- write.space();
27
- maybe.write(isRight, '(');
28
- traverse(right);
29
- maybe.write(isRight, ')');
30
- }
@@ -41,7 +41,10 @@ module.exports.MemberExpression = (path, {print, maybe, traverse}) => {
41
41
  };
42
42
 
43
43
  module.exports.OptionalMemberExpression = (path, {print, maybe}) => {
44
- const {computed, optional} = path.node;
44
+ const {
45
+ computed,
46
+ optional,
47
+ } = path.node;
45
48
  print('__object');
46
49
  maybe.print(optional, '?');
47
50
  print('.');
@@ -80,4 +83,3 @@ function likeChain(path) {
80
83
 
81
84
  return calls.length > 1;
82
85
  }
83
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.95.0",
3
+ "version": "1.96.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",