@faasjs/deep_merge 0.0.2-beta.302 → 0.0.2-beta.320
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/{lib → dist}/index.d.ts +12 -11
- package/dist/index.js +76 -0
- package/dist/index.mjs +50 -0
- package/package.json +8 -13
- package/lib/index.es.js +0 -37
- package/lib/index.js +0 -42
package/{lib → dist}/index.d.ts
RENAMED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 合并对象
|
|
3
|
-
* @description
|
|
4
|
-
* 注意事项:
|
|
5
|
-
* * 合并时会复制对象,不会修改原对象
|
|
6
|
-
* * 合并顺序是后面的覆盖前面的
|
|
7
|
-
* * 若有数组形式的属性,数组里的内容将被去重合并
|
|
8
|
-
* @param sources [...any] 合并对象
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 合并对象
|
|
3
|
+
* @description
|
|
4
|
+
* 注意事项:
|
|
5
|
+
* * 合并时会复制对象,不会修改原对象
|
|
6
|
+
* * 合并顺序是后面的覆盖前面的
|
|
7
|
+
* * 若有数组形式的属性,数组里的内容将被去重合并
|
|
8
|
+
* @param sources [...any] 合并对象
|
|
9
|
+
*/
|
|
10
|
+
declare function deepMerge(...sources: any[]): any;
|
|
11
|
+
|
|
12
|
+
export { deepMerge, deepMerge as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
28
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(module2))
|
|
30
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
31
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
36
|
+
return (module2, temp) => {
|
|
37
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
38
|
+
};
|
|
39
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
var src_exports = {};
|
|
43
|
+
__export(src_exports, {
|
|
44
|
+
deepMerge: () => deepMerge,
|
|
45
|
+
default: () => src_default
|
|
46
|
+
});
|
|
47
|
+
var shouldMerge = function(item) {
|
|
48
|
+
const type = Object.prototype.toString.call(item);
|
|
49
|
+
return type === "[object Object]" || type === "[object Array]";
|
|
50
|
+
};
|
|
51
|
+
function deepMerge(...sources) {
|
|
52
|
+
let acc = Object.create(null);
|
|
53
|
+
for (const source of sources)
|
|
54
|
+
if (source instanceof Array) {
|
|
55
|
+
if (!(acc instanceof Array))
|
|
56
|
+
acc = [];
|
|
57
|
+
acc = [...new Set(source.concat(...acc))];
|
|
58
|
+
} else if (shouldMerge(source))
|
|
59
|
+
for (const [key, value] of Object.entries(source)) {
|
|
60
|
+
let val;
|
|
61
|
+
if (shouldMerge(value))
|
|
62
|
+
val = deepMerge(acc[key], value);
|
|
63
|
+
else
|
|
64
|
+
val = value;
|
|
65
|
+
acc = __spreadProps(__spreadValues({}, acc), {
|
|
66
|
+
[key]: val
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return acc;
|
|
70
|
+
}
|
|
71
|
+
var src_default = deepMerge;
|
|
72
|
+
module.exports = __toCommonJS(src_exports);
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
deepMerge
|
|
76
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var shouldMerge = function(item) {
|
|
23
|
+
const type = Object.prototype.toString.call(item);
|
|
24
|
+
return type === "[object Object]" || type === "[object Array]";
|
|
25
|
+
};
|
|
26
|
+
function deepMerge(...sources) {
|
|
27
|
+
let acc = Object.create(null);
|
|
28
|
+
for (const source of sources)
|
|
29
|
+
if (source instanceof Array) {
|
|
30
|
+
if (!(acc instanceof Array))
|
|
31
|
+
acc = [];
|
|
32
|
+
acc = [...new Set(source.concat(...acc))];
|
|
33
|
+
} else if (shouldMerge(source))
|
|
34
|
+
for (const [key, value] of Object.entries(source)) {
|
|
35
|
+
let val;
|
|
36
|
+
if (shouldMerge(value))
|
|
37
|
+
val = deepMerge(acc[key], value);
|
|
38
|
+
else
|
|
39
|
+
val = value;
|
|
40
|
+
acc = __spreadProps(__spreadValues({}, acc), {
|
|
41
|
+
[key]: val
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
}
|
|
46
|
+
var src_default = deepMerge;
|
|
47
|
+
export {
|
|
48
|
+
deepMerge,
|
|
49
|
+
src_default as default
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/deep_merge",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.320",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"module": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
8
|
"homepage": "https://faasjs.com/doc/deep_merge.html",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -16,22 +16,17 @@
|
|
|
16
16
|
},
|
|
17
17
|
"funding": "https://github.com/sponsors/faasjs",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"prepack": "rm -rf ./lib && rollup -c"
|
|
19
|
+
"build": "rm -rf ./dist && tsup-node src/index.ts --format esm,cjs --dts"
|
|
21
20
|
},
|
|
22
21
|
"files": [
|
|
23
|
-
"
|
|
22
|
+
"dist"
|
|
24
23
|
],
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"@types/jest": "*",
|
|
28
|
-
"@types/node": "*",
|
|
29
|
-
"rollup": "*",
|
|
30
|
-
"rollup-plugin-typescript2": "*",
|
|
25
|
+
"tsup": "*",
|
|
31
26
|
"typescript": "*"
|
|
32
27
|
},
|
|
33
28
|
"engines": {
|
|
34
29
|
"npm": ">=8.0.0"
|
|
35
30
|
},
|
|
36
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "4a9f699171ad7e20d922e68b74418d1ec5b7d016"
|
|
37
32
|
}
|
package/lib/index.es.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const shouldMerge = function (item) {
|
|
2
|
-
const type = Object.prototype.toString.call(item);
|
|
3
|
-
return type === '[object Object]' || type === '[object Array]';
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* 合并对象
|
|
7
|
-
* @description
|
|
8
|
-
* 注意事项:
|
|
9
|
-
* * 合并时会复制对象,不会修改原对象
|
|
10
|
-
* * 合并顺序是后面的覆盖前面的
|
|
11
|
-
* * 若有数组形式的属性,数组里的内容将被去重合并
|
|
12
|
-
* @param sources [...any] 合并对象
|
|
13
|
-
*/
|
|
14
|
-
function deepMerge(...sources) {
|
|
15
|
-
let acc = Object.create(null);
|
|
16
|
-
for (const source of sources)
|
|
17
|
-
if (source instanceof Array) {
|
|
18
|
-
if (!(acc instanceof Array))
|
|
19
|
-
acc = [];
|
|
20
|
-
acc = [...new Set((source).concat(...acc))];
|
|
21
|
-
}
|
|
22
|
-
else if (shouldMerge(source))
|
|
23
|
-
for (const [key, value] of Object.entries(source)) {
|
|
24
|
-
let val;
|
|
25
|
-
if (shouldMerge(value))
|
|
26
|
-
val = deepMerge(acc[key], value);
|
|
27
|
-
else
|
|
28
|
-
val = value;
|
|
29
|
-
acc = {
|
|
30
|
-
...acc,
|
|
31
|
-
[key]: val
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return acc;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { deepMerge, deepMerge as default };
|
package/lib/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const shouldMerge = function (item) {
|
|
6
|
-
const type = Object.prototype.toString.call(item);
|
|
7
|
-
return type === '[object Object]' || type === '[object Array]';
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* 合并对象
|
|
11
|
-
* @description
|
|
12
|
-
* 注意事项:
|
|
13
|
-
* * 合并时会复制对象,不会修改原对象
|
|
14
|
-
* * 合并顺序是后面的覆盖前面的
|
|
15
|
-
* * 若有数组形式的属性,数组里的内容将被去重合并
|
|
16
|
-
* @param sources [...any] 合并对象
|
|
17
|
-
*/
|
|
18
|
-
function deepMerge(...sources) {
|
|
19
|
-
let acc = Object.create(null);
|
|
20
|
-
for (const source of sources)
|
|
21
|
-
if (source instanceof Array) {
|
|
22
|
-
if (!(acc instanceof Array))
|
|
23
|
-
acc = [];
|
|
24
|
-
acc = [...new Set((source).concat(...acc))];
|
|
25
|
-
}
|
|
26
|
-
else if (shouldMerge(source))
|
|
27
|
-
for (const [key, value] of Object.entries(source)) {
|
|
28
|
-
let val;
|
|
29
|
-
if (shouldMerge(value))
|
|
30
|
-
val = deepMerge(acc[key], value);
|
|
31
|
-
else
|
|
32
|
-
val = value;
|
|
33
|
-
acc = {
|
|
34
|
-
...acc,
|
|
35
|
-
[key]: val
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return acc;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.deepMerge = deepMerge;
|
|
42
|
-
exports["default"] = deepMerge;
|