@arrai-innovations/reactive-helpers 4.1.3 → 4.2.0
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/package.json
CHANGED
|
@@ -116,14 +116,7 @@ export function assignReactiveObject(target, source, exclude = []) {
|
|
|
116
116
|
addOrUpdateReactiveObject(target, source, exclude, addedKeys, sameKeys);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
function
|
|
120
|
-
let addedKeys, sameKeys, removedKeys;
|
|
121
|
-
try {
|
|
122
|
-
({ addedKeys, sameKeys, removedKeys } = keyDiff(Object.keys(source) || [], Object.keys(target) || []));
|
|
123
|
-
} catch (error) {
|
|
124
|
-
debugger;
|
|
125
|
-
}
|
|
126
|
-
trimReactiveObject(target, removedKeys, exclude);
|
|
119
|
+
function recursiveInner(target, source, exclude, addedKeys, sameKeys, path, fn) {
|
|
127
120
|
addReactiveObject(target, source, exclude, addedKeys);
|
|
128
121
|
const keysForRecurse = [];
|
|
129
122
|
const keysForReplace = [];
|
|
@@ -143,10 +136,16 @@ function assignReactiveObjectRecursive(target, source, exclude = [], path = "")
|
|
|
143
136
|
.filter((excludeKey) => !excludeKey.startsWith(path))
|
|
144
137
|
.map((excludeKey) => excludeKey.replace(path, ""));
|
|
145
138
|
const nextPath = isArray(source[key]) ? `${path}[${key}]` : `${path}.${key}`;
|
|
146
|
-
|
|
139
|
+
fn(target[key], source[key], nextLevelExclude, nextPath);
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
|
|
143
|
+
function assignReactiveObjectRecursive(target, source, exclude = [], path = "") {
|
|
144
|
+
let { addedKeys, sameKeys, removedKeys } = keyDiff(Object.keys(source) || [], Object.keys(target) || []);
|
|
145
|
+
trimReactiveObject(target, removedKeys, exclude);
|
|
146
|
+
recursiveInner(target, source, exclude, addedKeys, sameKeys, path, assignReactiveObjectRecursive);
|
|
147
|
+
}
|
|
148
|
+
|
|
150
149
|
export function assignReactiveObjectDeep(target, source, exclude = []) {
|
|
151
150
|
// exclude keys will need to be lodash get strings
|
|
152
151
|
if (target === source) {
|
|
@@ -155,3 +154,18 @@ export function assignReactiveObjectDeep(target, source, exclude = []) {
|
|
|
155
154
|
({ target, source } = validateTargetAndSource(target, source));
|
|
156
155
|
assignReactiveObjectRecursive(target, source, exclude);
|
|
157
156
|
}
|
|
157
|
+
|
|
158
|
+
function addOrUpdateReactiveObjectRecursive(target, source, exclude = [], path = "") {
|
|
159
|
+
let addedKeys,
|
|
160
|
+
sameKeys = keyDiff(Object.keys(source) || [], Object.keys(target) || []);
|
|
161
|
+
recursiveInner(target, source, exclude, addedKeys, sameKeys, path, addOrUpdateReactiveObjectRecursive);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function addOrUpdateReactiveObjectDeep(target, source, exclude = []) {
|
|
165
|
+
// exclude keys will need to be lodash get strings
|
|
166
|
+
if (target === source) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
({ target, source } = validateTargetAndSource(target, source));
|
|
170
|
+
addOrUpdateReactiveObjectRecursive(target, source, exclude);
|
|
171
|
+
}
|