@putout/printer 18.8.5 → 18.8.6

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
+ 2026.03.20, v18.8.6
2
+
3
+ feature:
4
+ - 9e0406e2 @putout/printer: type-checker: maybeCutOptions
5
+
1
6
  2026.03.20, v18.8.5
2
7
 
3
8
  feature:
@@ -32,13 +32,10 @@ function hasPropertyLeadingComment(path) {
32
32
  return false;
33
33
  }
34
34
 
35
- const cutOptions = (fn) => (a) => fn(a);
36
- const isFunctionLike = cutOptions(isFunction);
37
-
38
35
  const isFunctionParam = callWithParent(createTypeChecker([
39
- ['+', isFunctionLike],
36
+ ['+', isFunction],
40
37
  ['-: -> !AssignmentPattern'],
41
- ['+: parentPath', isFunctionLike],
38
+ ['+: parentPath', isFunction],
42
39
  ]));
43
40
 
44
41
  const isOneOfIdentifiersHasMoreLength = createTypeChecker([
@@ -68,7 +65,9 @@ function isCoupleAssigns(path) {
68
65
  if (isFunctionParam(path))
69
66
  return false;
70
67
 
71
- const properties = path.node.properties
68
+ const properties = path
69
+ .node
70
+ .properties
72
71
  .filter(isObjectProperty)
73
72
  .map(getValue)
74
73
  .filter(isAssignmentPattern);
@@ -1,3 +1,5 @@
1
+ import {types} from '@putout/babel';
2
+
1
3
  const isFn = (a) => typeof a === 'function';
2
4
  const isString = (a) => typeof a === 'string';
3
5
  const maybeNot = (not, a) => not ? !a : a;
@@ -18,10 +20,19 @@ export const maybeCall = (fn, not, a, options) => {
18
20
  if (!isFn(fn))
19
21
  return false;
20
22
 
21
- const result = fn(a, options);
23
+ const result = maybeCutOptions(fn, a, options);
22
24
 
23
25
  if (not)
24
26
  return !result;
25
27
 
26
28
  return result;
27
29
  };
30
+
31
+ function maybeCutOptions(fn, a, options) {
32
+ const {name} = fn;
33
+
34
+ if (types[name] === fn)
35
+ return fn(a);
36
+
37
+ return fn(a, options);
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "18.8.5",
3
+ "version": "18.8.6",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",