deepie-merge 3.0.1 → 3.0.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 +12 -10
- package/dist/index.js +2 -2
- package/package.json +17 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
//#region index.d.ts
|
|
2
2
|
type ArrayExtend = boolean | Array<string>;
|
|
3
3
|
type DeepieMergeOpts<T = any> = {
|
|
4
|
-
/** Either a boolean or a array of property keys to allow extension. Default: false */
|
|
5
|
-
|
|
4
|
+
/** Either a boolean or a array of property keys to allow extension. Default: false */
|
|
5
|
+
arrayExtend?: ArrayExtend;
|
|
6
|
+
/** Maximum recursions to perform. Default: 10. */
|
|
7
|
+
maxRecursion?: number;
|
|
8
|
+
/** Return a new value instead of mutating the first argument. Default: false */
|
|
6
9
|
clone?: boolean | ((value: NoInfer<T>) => NoInfer<T>);
|
|
7
10
|
};
|
|
8
11
|
type DeepMergeable = {
|
|
9
12
|
[key: string]: any;
|
|
10
13
|
} | Array<any>;
|
|
11
|
-
|
|
14
|
+
/** Same top-level shape as `T` (array vs object) with the same keys, but with
|
|
15
|
+
* values widened to `unknown`. Catches array/object mismatches and top-level
|
|
16
|
+
* excess keys on fresh literals, while accepting wider override types
|
|
17
|
+
* (e.g. `Partial<UserConfig>` against a `satisfies`-narrowed literal). */
|
|
18
|
+
type DeepMergeSource<T> = T extends ReadonlyArray<any> ? ReadonlyArray<unknown> : T extends object ? { [K in keyof T]?: unknown; } : never;
|
|
12
19
|
/** deep-merge b into a */
|
|
13
|
-
declare function deepMerge<T extends DeepMergeable>(a: T, b: NoInfer<T> |
|
|
14
|
-
|
|
15
|
-
maxRecursion,
|
|
16
|
-
clone
|
|
17
|
-
}?: DeepieMergeOpts<T>): T;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { deepMerge };
|
|
20
|
+
export declare function deepMerge<T extends DeepMergeable>(a: T, b: NoInfer<T> | DeepMergeSource<NoInfer<T>> | null | undefined, { arrayExtend, maxRecursion, clone }?: DeepieMergeOpts<T>): T;
|
|
21
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function deepMerge(a, b, { arrayExtend = false, maxRecursion = 20, clone = false
|
|
|
17
17
|
function merge(a, b, arrayExtend, maxRecursion) {
|
|
18
18
|
if (maxRecursion === 0) return a;
|
|
19
19
|
if (Array.isArray(a)) {
|
|
20
|
-
if (Array.isArray(b)) return arrayExtend ? Array.from(new Set([...a, ...b])) : b;
|
|
20
|
+
if (Array.isArray(b)) return arrayExtend ? Array.from(/* @__PURE__ */ new Set([...a, ...b])) : b;
|
|
21
21
|
return b;
|
|
22
22
|
}
|
|
23
23
|
if (Array.isArray(b)) return b;
|
|
@@ -27,7 +27,7 @@ function merge(a, b, arrayExtend, maxRecursion) {
|
|
|
27
27
|
const key = keys[i];
|
|
28
28
|
const typeA = getType(a[key]);
|
|
29
29
|
if (typeA !== getType(b[key])) a[key] = b[key];
|
|
30
|
-
else if (typeA === "array" && (Array.isArray(arrayExtend) ? arrayExtend.includes(key) : arrayExtend)) a[key] = Array.from(new Set([...a[key], ...b[key]]));
|
|
30
|
+
else if (typeA === "array" && (Array.isArray(arrayExtend) ? arrayExtend.includes(key) : arrayExtend)) a[key] = Array.from(/* @__PURE__ */ new Set([...a[key], ...b[key]]));
|
|
31
31
|
else if (typeA === "object") a[key] = merge(a[key], b[key], arrayExtend, maxRecursion - 1);
|
|
32
32
|
else a[key] = b[key];
|
|
33
33
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepie-merge",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Yay, another deep merge",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/silverwind/deepie-merge.git"
|
|
9
|
+
},
|
|
7
10
|
"license": "BSD-2-Clause",
|
|
8
11
|
"type": "module",
|
|
9
12
|
"sideEffects": false,
|
|
@@ -17,19 +20,19 @@
|
|
|
17
20
|
"node": ">=22"
|
|
18
21
|
},
|
|
19
22
|
"devDependencies": {
|
|
20
|
-
"@types/node": "
|
|
21
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
22
|
-
"eslint": "10.
|
|
23
|
-
"eslint-config-silverwind": "
|
|
23
|
+
"@types/node": "26.6.2",
|
|
24
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
25
|
+
"eslint": "10.11.0",
|
|
26
|
+
"eslint-config-silverwind": "151.0.0",
|
|
24
27
|
"jest-extended": "7.0.0",
|
|
25
|
-
"tsdown": "0.
|
|
26
|
-
"tsdown-config-silverwind": "
|
|
28
|
+
"tsdown": "0.23.0",
|
|
29
|
+
"tsdown-config-silverwind": "4.1.1",
|
|
27
30
|
"typescript": "6.0.3",
|
|
28
|
-
"typescript-config-silverwind": "
|
|
29
|
-
"updates": "
|
|
30
|
-
"updates-config-silverwind": "
|
|
31
|
-
"versions": "15.0
|
|
32
|
-
"vitest": "
|
|
33
|
-
"vitest-config-silverwind": "
|
|
31
|
+
"typescript-config-silverwind": "21.0.0",
|
|
32
|
+
"updates": "19.0.0",
|
|
33
|
+
"updates-config-silverwind": "4.0.6",
|
|
34
|
+
"versions": "15.5.0",
|
|
35
|
+
"vitest": "5.0.2",
|
|
36
|
+
"vitest-config-silverwind": "12.0.4"
|
|
34
37
|
}
|
|
35
38
|
}
|