@putout/printer 1.4.1 → 1.4.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/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.03.18, v1.4.2
2
+
3
+ feature:
4
+ - fe8c410 @putout/printer: add support of AwaitExpression
5
+
1
6
  2023.03.17, v1.4.1
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [NPMIMGURL]: https://img.shields.io/npm/v/@putout/printer.svg?style=flat&longCache=true
4
4
  [NPMURL]: https://npmjs.org/package/@putout/printer "npm"
5
5
 
6
- **@putout/printer** prints [**Babel AST**](https://github.com/coderaiser/estree-to-babel) to readable **JavaScript**.
6
+ Prints [**Babel AST**](https://github.com/coderaiser/estree-to-babel) to readable **JavaScript**.
7
7
 
8
8
  - ☝️ Similar to **Recast**, but simpler and easier in maintenance, since it supports only **Babel**.
9
9
  - ☝️ As opinionated as **Prettier**, but has more user-friendly output and works directly with **AST**.
@@ -3,7 +3,10 @@
3
3
  const {isMarkedPrevAfter} = require('../mark');
4
4
  const isFirst = (path) => path.node === path.parentPath.node.body[0];
5
5
 
6
- module.exports.ArrowFunctionExpression = (path, {write, traverse}) => {
6
+ module.exports.ArrowFunctionExpression = (path, {write, maybe, traverse}) => {
7
+ const {async} = path.node;
8
+ maybe.write(async, 'async ');
9
+
7
10
  write('(');
8
11
 
9
12
  const params = path.get('params');
@@ -38,10 +41,14 @@ module.exports.ObjectMethod = (path, {write, traverse}) => {
38
41
  traverse(path.get('body'));
39
42
  };
40
43
 
41
- module.exports.FunctionDeclaration = (path, {write, traverse}) => {
44
+ module.exports.FunctionDeclaration = (path, {write, maybe, traverse}) => {
45
+ const {async} = path.node;
46
+
42
47
  if (!isFirst(path) && !isMarkedPrevAfter(path))
43
48
  write('\n');
44
49
 
50
+ maybe.write(async, 'async ');
51
+
45
52
  write('function ');
46
53
  traverse(path.get('id'));
47
54
  write('(');
@@ -2,6 +2,10 @@
2
2
 
3
3
  module.exports.UnaryExpression = unaryExpressions;
4
4
  module.exports.UpdateExpression = unaryExpressions;
5
+ module.exports.AwaitExpression = (path, {write, traverse}) => {
6
+ write('await ');
7
+ traverse(path.get('argument'));
8
+ };
5
9
 
6
10
  const isWord = (a) => /delete|typeof/.test(a);
7
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",