@putout/printer 2.18.0 → 2.19.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.06.16, v2.19.0
2
+
3
+ feature:
4
+ - 8b5f8c4 @putout/printer: BinaryExpression: minification of UnaryExpression (coderaiser/minify#105)
5
+
1
6
  2023.06.15, v2.18.0
2
7
 
3
8
  feature:
@@ -4,6 +4,7 @@ const {
4
4
  concatanate,
5
5
  isConcatenation,
6
6
  } = require('./concatanate');
7
+ const {maybeSpace} = require('./maybe-space');
7
8
 
8
9
  const BinaryExpression = {
9
10
  condition(path) {
@@ -38,7 +39,7 @@ const BinaryExpression = {
38
39
  print('__left');
39
40
  print.space();
40
41
  print(path.node.operator);
41
- print.space();
42
+ maybeSpace(path, {print});
42
43
  print('__right');
43
44
  },
44
45
  after(path, {print}) {
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ module.exports.maybeSpace = (path, {print}) => {
4
+ const {right} = path.node;
5
+
6
+ if (right.type === 'UnaryExpression' && right.operator === '+')
7
+ return print(' ');
8
+
9
+ return print.space();
10
+ };
11
+
@@ -175,4 +175,3 @@ const isNextAssign = (path) => {
175
175
  .get('expression')
176
176
  .isAssignmentExpression();
177
177
  };
178
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.18.0",
3
+ "version": "2.19.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",