@putout/printer 1.6.0 → 1.6.1

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.20, v1.6.1
2
+
3
+ fix:
4
+ - 7e8d47c @putout/printer: visitors
5
+
1
6
  2023.03.20, v1.6.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -48,9 +48,12 @@ Here is how you can override `AssignmentPattern`:
48
48
  const ast = parse('const {a = 5} = b');
49
49
 
50
50
  print(ast, {
51
- AssignmentPattern(path, {print}) {
52
- print(' /* [hello world] */= ');
53
- print('__right');
51
+ indent: ' ',
52
+ visitors: {
53
+ AssignmentPattern(path, {print}) {
54
+ print(' /* [hello world] */= ');
55
+ print('__right');
56
+ },
54
57
  },
55
58
  });
56
59
 
@@ -25,7 +25,7 @@ const traversers = {
25
25
  const GET = '__';
26
26
  const get = (path, command) => path.get(command.replace(GET, ''));
27
27
 
28
- module.exports.tokenize = (ast, overrides) => {
28
+ module.exports.tokenize = (ast, overrides = {}) => {
29
29
  const tokens = [];
30
30
  const debug = createDebug(tokens);
31
31
  const write = (value) => {
@@ -85,14 +85,11 @@ module.exports.tokenize = (ast, overrides) => {
85
85
  breakline,
86
86
  });
87
87
 
88
- //const maybePrint = (a, b) => a && print(b);
89
-
90
88
  const maybe = {
91
89
  write: maybeWrite,
92
90
  indent: maybeIndent,
93
91
  markBefore: maybeMarkBefore,
94
92
  markAfter: maybeMarkAfter,
95
- //print: maybePrint,
96
93
  };
97
94
 
98
95
  assign(maybe.indent, {
@@ -100,8 +97,6 @@ module.exports.tokenize = (ast, overrides) => {
100
97
  dec: maybeIndentDec,
101
98
  });
102
99
 
103
- //assign(print, write);
104
-
105
100
  const printer = {
106
101
  incIndent,
107
102
  decIndent,
@@ -116,7 +111,7 @@ module.exports.tokenize = (ast, overrides) => {
116
111
 
117
112
  const currentTraversers = {
118
113
  ...traversers,
119
- ...overrides,
114
+ ...overrides.visitors,
120
115
  };
121
116
 
122
117
  babelTraverse(ast, {
@@ -171,12 +166,6 @@ function printIndent(i) {
171
166
  return result;
172
167
  }
173
168
 
174
- /*
175
- const createCompute = (path, {traverse}) => (maybeLine) => {
176
- if (maybeLine.startsWith(GET))
177
- return traverse(get(path, maybeLine));
178
- };
179
- */
180
169
  const createPrint = (path, {traverse, write}) => (maybeLine) => {
181
170
  if (maybeLine === path)
182
171
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
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",