putout 36.0.0 → 36.0.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.
Files changed (3) hide show
  1. package/ChangeLog +12 -0
  2. package/lib/merge.js +16 -4
  3. package/package.json +2 -2
package/ChangeLog CHANGED
@@ -1,3 +1,15 @@
1
+ 2024.07.19, v36.0.2
2
+
3
+ feature:
4
+ - 04f19efba putout: merge: printer (#213)
5
+
6
+ 2024.07.18, v36.0.1
7
+
8
+ feature:
9
+ - b6b1730e6 putout: @putout/plugin-remove-useless-variables v12.0.0
10
+ - d1be29ed0 @putout/plugin-remove-useless-variables: drop support of 🐊 < 36
11
+ - 9055ae93e @putout/plugin-remove-useless-variables: remove: init is MemberExpression (coderaiser/minify#125)
12
+
1
13
  2024.07.16, v36.0.0
2
14
 
3
15
  feature:
package/lib/merge.js CHANGED
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const deepmerge = require('deepmerge');
4
+
4
5
  const {isArray} = Array;
6
+ const isObject = (a) => typeof a === 'object';
5
7
  const isNested = (a) => isArray(a[0]) && a[0].length > 1;
8
+ const isStringObjectTuple = (a) => isArray(a) && isString(a[0]) && isObject(a[1]);
6
9
 
7
10
  const isString = (a) => typeof a === 'string';
8
11
  const arrayUnion = (a, b) => {
@@ -12,10 +15,19 @@ const arrayUnion = (a, b) => {
12
15
  if (isNested(a))
13
16
  return a;
14
17
 
15
- const flatten = [
16
- ...a,
17
- ...b,
18
- ].flat();
18
+ let flatten = [];
19
+
20
+ if (isStringObjectTuple(a) && isStringObjectTuple(b))
21
+ flatten = [
22
+ a[0],
23
+ b[0],
24
+ deepmerge(a[1], b[1]),
25
+ ];
26
+ else
27
+ flatten = [
28
+ ...a,
29
+ ...b,
30
+ ].flat();
19
31
 
20
32
  return mergeIgnore(Array.from(new Set(flatten)));
21
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "36.0.0",
3
+ "version": "36.0.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -171,7 +171,7 @@
171
171
  "@putout/plugin-remove-useless-return": "^7.0.0",
172
172
  "@putout/plugin-remove-useless-spread": "^11.0.0",
173
173
  "@putout/plugin-remove-useless-template-expressions": "^2.0.0",
174
- "@putout/plugin-remove-useless-variables": "^11.0.0",
174
+ "@putout/plugin-remove-useless-variables": "^12.0.0",
175
175
  "@putout/plugin-reuse-duplicate-init": "^5.0.0",
176
176
  "@putout/plugin-simplify-assignment": "^3.0.0",
177
177
  "@putout/plugin-simplify-boolean-return": "^2.0.0",