@modern-js/runtime-utils 2.56.2 → 2.57.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/dist/cjs/merge.js +53 -0
- package/dist/esm/merge.js +32 -0
- package/dist/esm-node/merge.js +29 -0
- package/dist/types/merge.d.ts +6 -0
- package/package.json +13 -5
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var merge_exports = {};
|
|
20
|
+
__export(merge_exports, {
|
|
21
|
+
merge: () => merge
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(merge_exports);
|
|
24
|
+
function isObject(obj) {
|
|
25
|
+
return obj && typeof obj === "object" && !Array.isArray(obj);
|
|
26
|
+
}
|
|
27
|
+
function merge(target, ...sources) {
|
|
28
|
+
if (!sources.length) {
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
const source = sources.shift();
|
|
32
|
+
if (isObject(target) && isObject(source)) {
|
|
33
|
+
for (const key in source) {
|
|
34
|
+
if (isObject(source[key])) {
|
|
35
|
+
if (!target[key]) {
|
|
36
|
+
Object.assign(target, {
|
|
37
|
+
[key]: {}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
merge(target[key], source[key]);
|
|
41
|
+
} else {
|
|
42
|
+
Object.assign(target, {
|
|
43
|
+
[key]: source[key]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return merge(target, ...sources);
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
merge
|
|
53
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
|
+
function isObject(obj) {
|
|
4
|
+
return obj && typeof obj === "object" && !Array.isArray(obj);
|
|
5
|
+
}
|
|
6
|
+
function merge(target) {
|
|
7
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
8
|
+
sources[_key - 1] = arguments[_key];
|
|
9
|
+
}
|
|
10
|
+
if (!sources.length) {
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
var source = sources.shift();
|
|
14
|
+
if (isObject(target) && isObject(source)) {
|
|
15
|
+
for (var key in source) {
|
|
16
|
+
if (isObject(source[key])) {
|
|
17
|
+
if (!target[key]) {
|
|
18
|
+
Object.assign(target, _define_property({}, key, {}));
|
|
19
|
+
}
|
|
20
|
+
merge(target[key], source[key]);
|
|
21
|
+
} else {
|
|
22
|
+
Object.assign(target, _define_property({}, key, source[key]));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return merge.apply(void 0, [
|
|
27
|
+
target
|
|
28
|
+
].concat(_to_consumable_array(sources)));
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
merge
|
|
32
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function isObject(obj) {
|
|
2
|
+
return obj && typeof obj === "object" && !Array.isArray(obj);
|
|
3
|
+
}
|
|
4
|
+
function merge(target, ...sources) {
|
|
5
|
+
if (!sources.length) {
|
|
6
|
+
return target;
|
|
7
|
+
}
|
|
8
|
+
const source = sources.shift();
|
|
9
|
+
if (isObject(target) && isObject(source)) {
|
|
10
|
+
for (const key in source) {
|
|
11
|
+
if (isObject(source[key])) {
|
|
12
|
+
if (!target[key]) {
|
|
13
|
+
Object.assign(target, {
|
|
14
|
+
[key]: {}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
merge(target[key], source[key]);
|
|
18
|
+
} else {
|
|
19
|
+
Object.assign(target, {
|
|
20
|
+
[key]: source[key]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return merge(target, ...sources);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
merge
|
|
29
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type PlainObject = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
+
export declare function merge<T extends PlainObject, U extends PlainObject[]>(target: T, ...sources: U): T & UnionToIntersection<U[number]>;
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.57.0",
|
|
19
19
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
20
20
|
"exports": {
|
|
21
21
|
"./router": {
|
|
@@ -72,6 +72,11 @@
|
|
|
72
72
|
"types": "./dist/types/url.d.ts",
|
|
73
73
|
"require": "./dist/cjs/url.js",
|
|
74
74
|
"default": "./dist/esm/url.js"
|
|
75
|
+
},
|
|
76
|
+
"./merge": {
|
|
77
|
+
"types": "./dist/types/merge.d.ts",
|
|
78
|
+
"require": "./dist/cjs/merge.js",
|
|
79
|
+
"default": "./dist/esm/merge.js"
|
|
75
80
|
}
|
|
76
81
|
},
|
|
77
82
|
"publishConfig": {
|
|
@@ -113,6 +118,9 @@
|
|
|
113
118
|
],
|
|
114
119
|
"url": [
|
|
115
120
|
"./dist/types/url.d.ts"
|
|
121
|
+
],
|
|
122
|
+
"merge": [
|
|
123
|
+
"./dist/types/merge.d.ts"
|
|
116
124
|
]
|
|
117
125
|
}
|
|
118
126
|
},
|
|
@@ -122,7 +130,7 @@
|
|
|
122
130
|
"react-router-dom": "6.22.0",
|
|
123
131
|
"@remix-run/router": "1.15.0",
|
|
124
132
|
"@swc/helpers": "0.5.3",
|
|
125
|
-
"@modern-js/utils": "2.
|
|
133
|
+
"@modern-js/utils": "2.57.0"
|
|
126
134
|
},
|
|
127
135
|
"peerDependencies": {
|
|
128
136
|
"react": ">=17.0.0",
|
|
@@ -145,9 +153,9 @@
|
|
|
145
153
|
"jest": "^29",
|
|
146
154
|
"typescript": "^5",
|
|
147
155
|
"@types/serialize-javascript": "^5.0.1",
|
|
148
|
-
"@
|
|
149
|
-
"@scripts/
|
|
150
|
-
"@
|
|
156
|
+
"@scripts/build": "2.57.0",
|
|
157
|
+
"@scripts/jest-config": "2.57.0",
|
|
158
|
+
"@modern-js/types": "2.57.0"
|
|
151
159
|
},
|
|
152
160
|
"sideEffects": false,
|
|
153
161
|
"scripts": {
|