@bbn/bbn 2.0.180 → 2.0.184
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/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/fn/object/mutateObject.js +11 -1
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@ import isObject from '../type/isObject.js';
|
|
|
2
2
|
import hash from '../string/hash.js';
|
|
3
3
|
import isSame from '../type/isSame.js';
|
|
4
4
|
import checkType from '../type/checkType.js';
|
|
5
|
+
import isArray from '../type/isArray.js';
|
|
6
|
+
import mutateArray from './mutateArray.js';
|
|
5
7
|
export default function mutateObject(a1, a2, hashFn) {
|
|
6
8
|
if (!isObject(a1, a2)) {
|
|
7
|
-
throw new TypeError('mutateObject can only be called with
|
|
9
|
+
throw new TypeError('mutateObject can only be called with objects parameters');
|
|
8
10
|
}
|
|
9
11
|
if (hashFn) {
|
|
10
12
|
checkType(hashFn, 'function', 'The hash function must be a function');
|
|
@@ -21,6 +23,14 @@ export default function mutateObject(a1, a2, hashFn) {
|
|
|
21
23
|
}
|
|
22
24
|
mapA2.forEach(n => {
|
|
23
25
|
if (!isSame(a1[n], a2[n])) {
|
|
26
|
+
if (isObject(a1[n], a2[n])) {
|
|
27
|
+
mutateObject(a1[n], a2[n], hashFn);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (isArray(a1[n], a2[n])) {
|
|
31
|
+
mutateArray(a1[n], a2[n], hashFn);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
24
34
|
a1[n] = a2[n];
|
|
25
35
|
}
|
|
26
36
|
});
|