merge-anything 2.4.0 → 2.4.4

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.
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: mesqueeb
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
package/README.md CHANGED
@@ -14,6 +14,8 @@ I was looking for:
14
14
 
15
15
  - a simple merge function like `Object.assign()`
16
16
  - supports merging of nested properties
17
+ - supports symbols
18
+ - supports enumerable & nonenumerable props
17
19
  - **does not break special class instances** ‼️
18
20
 
19
21
  This last one is crucial! In JavaScript almost everything is _an object_, sure, but I don't want a merge function trying to merge eg. two `new Date()` instances! So many libraries use custom classes that create objects with special prototypes, and such objects all break when trying to merge them. So we gotta be careful!
@@ -186,7 +188,7 @@ const merged = copy(merge(original, extraInfo))
186
188
  merged.airport.airplane = 'lan. 🛬'
187
189
  (merged.airport.airplane === 'lan. 🛬') // true
188
190
  // `original` won't be modified!
189
- (original.airport.airplane === 'lan. 🛬') // true
191
+ (original.airport.airplane === 'dep. 🛫') // true
190
192
  ```
191
193
 
192
194
  You can then play around where you want to place the `copy()` function.
@@ -230,4 +232,4 @@ function mergeRecursively (origin, newComer) {
230
232
  }
231
233
  ```
232
234
 
233
- \* Of course, there are small differences with the actual source code to cope with rare cases & extra features. The actual source code is [here](https://github.com/mesqueeb/merge-anything/blob/master/src/index.js).
235
+ \* Of course, there are small differences with the actual source code to cope with rare cases & extra features. The actual source code is [here](https://github.com/mesqueeb/merge-anything/blob/master/src/merge.ts).
package/dist/index.cjs.js CHANGED
@@ -4,6 +4,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var isWhat = require('is-what');
6
6
 
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
+ this file except in compliance with the License. You may obtain a copy of the
11
+ License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
+ MERCHANTABLITY OR NON-INFRINGEMENT.
17
+
18
+ See the Apache Version 2.0 License for specific language governing permissions
19
+ and limitations under the License.
20
+ ***************************************************************************** */
21
+
22
+ function __spreadArrays() {
23
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
24
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
25
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
26
+ r[k] = a[j];
27
+ return r;
28
+ }
29
+
7
30
  function assignProp(carry, key, newVal, originalObject) {
8
31
  var propType = originalObject.propertyIsEnumerable(key)
9
32
  ? 'enumerable'
@@ -35,7 +58,7 @@ function mergeRecursively(origin, newComer, extensions) {
35
58
  if (isWhat.isPlainObject(origin)) {
36
59
  var props_1 = Object.getOwnPropertyNames(origin);
37
60
  var symbols_1 = Object.getOwnPropertySymbols(origin);
38
- newObject = props_1.concat(symbols_1).reduce(function (carry, key) {
61
+ newObject = __spreadArrays(props_1, symbols_1).reduce(function (carry, key) {
39
62
  // @ts-ignore
40
63
  var targetVal = origin[key];
41
64
  if ((!isWhat.isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||
@@ -47,7 +70,7 @@ function mergeRecursively(origin, newComer, extensions) {
47
70
  }
48
71
  var props = Object.getOwnPropertyNames(newComer);
49
72
  var symbols = Object.getOwnPropertySymbols(newComer);
50
- var result = props.concat(symbols).reduce(function (carry, key) {
73
+ var result = __spreadArrays(props, symbols).reduce(function (carry, key) {
51
74
  // re-define the origin and newComer as targetVal and newVal
52
75
  var newVal = newComer[key];
53
76
  var targetVal = (isWhat.isPlainObject(origin))
@@ -102,6 +125,6 @@ function concatArrays(originVal, newVal) {
102
125
  return newVal; // always return newVal as fallback!!
103
126
  }
104
127
 
105
- exports.merge = merge;
106
128
  exports.concatArrays = concatArrays;
107
129
  exports.default = merge;
130
+ exports.merge = merge;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,27 @@
1
- import { isArray, isPlainObject, isSymbol } from 'is-what';
1
+ import { isPlainObject, isArray, isSymbol } from 'is-what';
2
+
3
+ /*! *****************************************************************************
4
+ Copyright (c) Microsoft Corporation. All rights reserved.
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12
+ MERCHANTABLITY OR NON-INFRINGEMENT.
13
+
14
+ See the Apache Version 2.0 License for specific language governing permissions
15
+ and limitations under the License.
16
+ ***************************************************************************** */
17
+
18
+ function __spreadArrays() {
19
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
20
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
21
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
22
+ r[k] = a[j];
23
+ return r;
24
+ }
2
25
 
3
26
  function assignProp(carry, key, newVal, originalObject) {
4
27
  var propType = originalObject.propertyIsEnumerable(key)
@@ -31,7 +54,7 @@ function mergeRecursively(origin, newComer, extensions) {
31
54
  if (isPlainObject(origin)) {
32
55
  var props_1 = Object.getOwnPropertyNames(origin);
33
56
  var symbols_1 = Object.getOwnPropertySymbols(origin);
34
- newObject = props_1.concat(symbols_1).reduce(function (carry, key) {
57
+ newObject = __spreadArrays(props_1, symbols_1).reduce(function (carry, key) {
35
58
  // @ts-ignore
36
59
  var targetVal = origin[key];
37
60
  if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||
@@ -43,7 +66,7 @@ function mergeRecursively(origin, newComer, extensions) {
43
66
  }
44
67
  var props = Object.getOwnPropertyNames(newComer);
45
68
  var symbols = Object.getOwnPropertySymbols(newComer);
46
- var result = props.concat(symbols).reduce(function (carry, key) {
69
+ var result = __spreadArrays(props, symbols).reduce(function (carry, key) {
47
70
  // re-define the origin and newComer as targetVal and newVal
48
71
  var newVal = newComer[key];
49
72
  var targetVal = (isPlainObject(origin))
@@ -99,4 +122,4 @@ function concatArrays(originVal, newVal) {
99
122
  }
100
123
 
101
124
  export default merge;
102
- export { merge, concatArrays };
125
+ export { concatArrays, merge };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-anything",
3
- "version": "2.4.0",
3
+ "version": "2.4.4",
4
4
  "description": "Merge objects & other types recursively. A simple & small integration.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -43,16 +43,16 @@
43
43
  },
44
44
  "homepage": "https://github.com/mesqueeb/merge-anything#readme",
45
45
  "devDependencies": {
46
- "@ava/babel-preset-stage-4": "^2.0.0",
47
- "@babel/plugin-proposal-object-rest-spread": "^7.5.4",
48
- "@babel/preset-env": "^7.5.4",
49
- "ava": "^1.4.1",
50
- "copy-anything": "^1.2.4",
51
- "rollup": "^0.65.2",
52
- "rollup-plugin-typescript2": "^0.21.2",
53
- "typescript": "^3.5.3"
46
+ "@ava/babel-preset-stage-4": "^4.0.0",
47
+ "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
48
+ "@babel/preset-env": "^7.7.1",
49
+ "ava": "^2.4.0",
50
+ "copy-anything": "^1.5.0",
51
+ "rollup": "^1.27.3",
52
+ "rollup-plugin-typescript2": "^0.25.2",
53
+ "typescript": "^3.7.2"
54
54
  },
55
55
  "dependencies": {
56
- "is-what": "^3.2.4"
56
+ "is-what": "^3.3.1"
57
57
  }
58
58
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import merge from './merge'
2
2
  import { concatArrays } from './extensions'
3
3
 
4
- export { merge, concatArrays }
4
+ export { concatArrays, merge }
5
5
  export default merge
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import merge from './merge';
2
2
  import { concatArrays } from './extensions';
3
- export { merge, concatArrays };
3
+ export { concatArrays, merge };
4
4
  export default merge;