@sladg/apex-state 3.7.1 → 3.7.3
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.d.ts +10 -4
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -602,10 +602,16 @@ type ComputationPair<DATA extends object, Depth extends number = DefaultDepth> =
|
|
|
602
602
|
type DeepRequired<T> = {
|
|
603
603
|
[K in keyof T]-?: NonNullable<T[K]> extends object ? DeepRequired<NonNullable<T[K]>> : NonNullable<T[K]>;
|
|
604
604
|
};
|
|
605
|
-
/**
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
605
|
+
/**
|
|
606
|
+
* Recursively makes all properties optional (allows undefined values).
|
|
607
|
+
*
|
|
608
|
+
* Written as a conditional type so TypeScript distributes it over union members
|
|
609
|
+
* automatically — null/undefined fall through to `: T` and are preserved as-is.
|
|
610
|
+
* Array check comes before object so arrays are not mapped over their keys.
|
|
611
|
+
*/
|
|
612
|
+
type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends readonly (infer U)[] ? readonly DeepPartial<U>[] : T extends object ? {
|
|
613
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
614
|
+
} : T;
|
|
609
615
|
|
|
610
616
|
interface BaseConcernProps<STATE, PATH extends string> {
|
|
611
617
|
state: STATE;
|
package/dist/index.js
CHANGED
|
@@ -2433,20 +2433,22 @@ var deepClone = (value) => {
|
|
|
2433
2433
|
var deepMerge = (target, source) => {
|
|
2434
2434
|
if (!source) return target;
|
|
2435
2435
|
const result = { ...target };
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
const
|
|
2436
|
+
const src = source;
|
|
2437
|
+
for (const key in src) {
|
|
2438
|
+
if (!Object.prototype.hasOwnProperty.call(src, key)) continue;
|
|
2439
|
+
const k = key;
|
|
2440
|
+
const sourceValue = src[k];
|
|
2441
|
+
const targetValue = target[k];
|
|
2440
2442
|
if (is.undefined(sourceValue)) {
|
|
2441
2443
|
continue;
|
|
2442
2444
|
}
|
|
2443
2445
|
if (is.object(sourceValue) && is.object(targetValue)) {
|
|
2444
|
-
result[
|
|
2446
|
+
result[k] = deepMerge(
|
|
2445
2447
|
targetValue,
|
|
2446
2448
|
sourceValue
|
|
2447
2449
|
);
|
|
2448
2450
|
} else {
|
|
2449
|
-
result[
|
|
2451
|
+
result[k] = sourceValue;
|
|
2450
2452
|
}
|
|
2451
2453
|
}
|
|
2452
2454
|
return result;
|