@putout/printer 2.53.0 → 2.55.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,13 @@
1
+ 2023.07.07, v2.55.0
2
+
3
+ feature:
4
+ - 0c2a787 @putout/printer: ForOfStatement: await
5
+
6
+ 2023.07.06, v2.54.0
7
+
8
+ feature:
9
+ - 0fe105a @putout/printer: TupleExpression: add support
10
+
1
11
  2023.07.06, v2.53.0
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -44,7 +44,7 @@ To benefit from it.
44
44
  ## API
45
45
 
46
46
  ```js
47
- const {write} = require('@putout/printer');
47
+ const {print} = require('@putout/printer');
48
48
  const {parse} = require('@babel/parser');
49
49
  const ast = parse('const a = (b, c) => {const d = 5; return a;}');
50
50
 
@@ -73,7 +73,7 @@ Here is how you can override `AssignmentPattern`:
73
73
  ```js
74
74
  const ast = parse('const {a = 5} = b');
75
75
 
76
- write(ast, {
76
+ print(ast, {
77
77
  format: {
78
78
  indent: ' ',
79
79
  newline: '\n',
@@ -168,7 +168,7 @@ Used in previous example `write` can be used for a couple purposes:
168
168
  - to write `node` when `string` started with `__`;
169
169
 
170
170
  ```js
171
- write(ast, {
171
+ print(ast, {
172
172
  visitors: {
173
173
  AssignmentPattern(path, {write, maybe}) {
174
174
  maybe.write.newline(path.parentPath.isCallExpression());
@@ -185,7 +185,7 @@ When you need some condition use `maybe`. For example, to add newline only when
185
185
  can use `maybe.write.newline(condition)`:
186
186
 
187
187
  ```js
188
- write(ast, {
188
+ print(ast, {
189
189
  visitors: {
190
190
  AssignmentPattern(path, {write, maybe}) {
191
191
  maybe.write.newline(path.parentPath.isCallExpression());
@@ -201,7 +201,7 @@ write(ast, {
201
201
  When are you going to output string you can use low-level function `write`:
202
202
 
203
203
  ```js
204
- write(ast, {
204
+ print(ast, {
205
205
  visitors: {
206
206
  BlockStatement(path, {write}) {
207
207
  write('hello');
@@ -216,7 +216,7 @@ When you need to add indentation use `indent`, for example when you output body,
216
216
  you need to increment indentation, and then decrement it back:
217
217
 
218
218
  ```js
219
- write(ast, {
219
+ print(ast, {
220
220
  visitors: {
221
221
  BlockStatement(path, {write, indent}) {
222
222
  write('{');
@@ -235,7 +235,7 @@ write(ast, {
235
235
  When are you needing to traverse node, you can use `traverse`:
236
236
 
237
237
  ```js
238
- write(ast, {
238
+ print(ast, {
239
239
  visitors: {
240
240
  AssignmentExpression(path, {traverse}) {
241
241
  traverse(path.get('left'));
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const {ArrayExpression} = require('./array-expression');
4
+ const {maybePlugin} = require('../../maybe');
5
+
6
+ module.exports.TupleExpression = (path, operations, semantics) => {
7
+ const {write} = operations;
8
+ write('#');
9
+ maybePlugin(ArrayExpression, path, operations, semantics);
10
+ };
@@ -43,6 +43,7 @@ const {
43
43
  const {ConditionalExpression} = require('./conditional-expression');
44
44
  const {StaticBlock} = require('./class/static-block');
45
45
  const {RecordExpression} = require('./object-expression/record-expression');
46
+ const {TupleExpression} = require('./array-expression/tuple-expression');
46
47
 
47
48
  module.exports = {
48
49
  ...functions,
@@ -75,4 +76,5 @@ module.exports = {
75
76
  write('this');
76
77
  },
77
78
  RecordExpression,
79
+ TupleExpression,
78
80
  };
@@ -5,13 +5,13 @@ const {
5
5
  markAfter,
6
6
  markBefore,
7
7
  isMarkedAfter,
8
- } = require('../mark');
8
+ } = require('../../mark');
9
9
 
10
10
  const {
11
11
  isFirst,
12
12
  isNext,
13
13
  isLast,
14
- } = require('../is');
14
+ } = require('../../is');
15
15
 
16
16
  module.exports.ForOfStatement = {
17
17
  beforeIf(path) {
@@ -27,8 +27,11 @@ module.exports.ForOfStatement = {
27
27
  markBefore(path);
28
28
  },
29
29
  print(path, {indent, print, maybe, traverse}) {
30
+ const {node} = path;
31
+
30
32
  indent();
31
33
  print('for');
34
+ maybe.print(node.await, ' await');
32
35
  print.space();
33
36
  print('(');
34
37
  print('__left');
@@ -3,7 +3,7 @@
3
3
  const {ExpressionStatement} = require('./expression-statement');
4
4
  const {VariableDeclaration} = require('./variable-declaration/variable-declaration');
5
5
  const {IfStatement} = require('./if-statement/if-statement');
6
- const {ForOfStatement} = require('./for-of-statement');
6
+ const {ForOfStatement} = require('./for-of-statement/for-of-statement');
7
7
  const {BlockStatement} = require('./block-statement/block-statement');
8
8
  const {ReturnStatement} = require('./return-statement/return-statement');
9
9
  const TryStatements = require('./try-statements');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.53.0",
3
+ "version": "2.55.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",