@ztimson/utils 0.26.25 → 0.26.26
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/index.cjs +7 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -126,10 +126,11 @@ ${opts.message || this.desc}`;
|
|
|
126
126
|
for (const [key, value] of Object.entries(delta)) {
|
|
127
127
|
if (value === null) {
|
|
128
128
|
delete target[key];
|
|
129
|
-
} else if (
|
|
130
|
-
|
|
129
|
+
} else if (Array.isArray(value)) {
|
|
130
|
+
target[key] = [...value];
|
|
131
|
+
} else if (typeof value === "object") {
|
|
132
|
+
if (typeof target[key] !== "object" || Array.isArray(target[key]) || !target[key])
|
|
131
133
|
target[key] = {};
|
|
132
|
-
}
|
|
133
134
|
applyDeltas(target[key], [value]);
|
|
134
135
|
} else {
|
|
135
136
|
target[key] = value;
|
|
@@ -148,7 +149,9 @@ ${opts.message || this.desc}`;
|
|
|
148
149
|
delta[key] = val1;
|
|
149
150
|
} else if (!(key in old)) {
|
|
150
151
|
delta[key] = null;
|
|
151
|
-
} else if (
|
|
152
|
+
} else if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
153
|
+
if (JSON.stringify(val1) !== JSON.stringify(val2)) delta[key] = val1;
|
|
154
|
+
} else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
|
|
152
155
|
const nested = calcDelta(val1, val2);
|
|
153
156
|
if (Object.keys(nested).length) delta[key] = nested;
|
|
154
157
|
} else if (val1 !== val2) {
|