@nocobase/utils 1.7.0-beta.13 → 1.7.0-beta.15
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/assign.js +18 -5
- package/lib/dayjs.js +2 -0
- package/package.json +2 -2
package/lib/assign.js
CHANGED
|
@@ -53,8 +53,14 @@ function getKeys(target) {
|
|
|
53
53
|
}
|
|
54
54
|
__name(getKeys, "getKeys");
|
|
55
55
|
const mergeStrategies = /* @__PURE__ */ new Map();
|
|
56
|
-
mergeStrategies.set("overwrite", (
|
|
57
|
-
if (
|
|
56
|
+
mergeStrategies.set("overwrite", (x, y) => {
|
|
57
|
+
if (y === void 0) {
|
|
58
|
+
if (typeof x === "string" && x.includes(",")) {
|
|
59
|
+
return x.split(",");
|
|
60
|
+
}
|
|
61
|
+
return x;
|
|
62
|
+
}
|
|
63
|
+
if (typeof y === "string" && y.includes(",")) {
|
|
58
64
|
y = y.split(",");
|
|
59
65
|
}
|
|
60
66
|
return y;
|
|
@@ -123,15 +129,22 @@ mergeStrategies.set(
|
|
|
123
129
|
})().filter(Boolean)
|
|
124
130
|
);
|
|
125
131
|
function assign(target, source, strategies = {}) {
|
|
126
|
-
getKeys(source)
|
|
132
|
+
const sourceKeys = getKeys(source);
|
|
133
|
+
const targetKeys = getKeys(target);
|
|
134
|
+
import_lodash.default.uniq([...sourceKeys, ...targetKeys]).forEach((sourceKey) => {
|
|
127
135
|
const strategy = strategies[sourceKey];
|
|
128
|
-
let func
|
|
136
|
+
let func;
|
|
129
137
|
if (typeof strategy === "function") {
|
|
130
138
|
func = strategy;
|
|
131
139
|
} else if (typeof strategy === "string" && mergeStrategies.has(strategy)) {
|
|
132
140
|
func = mergeStrategies.get(strategy);
|
|
133
141
|
}
|
|
134
|
-
|
|
142
|
+
if (func) {
|
|
143
|
+
target[sourceKey] = func(target[sourceKey], source[sourceKey]);
|
|
144
|
+
} else if (sourceKeys.includes(sourceKey)) {
|
|
145
|
+
const func2 = mergeStrategies.get("deepMerge");
|
|
146
|
+
target[sourceKey] = func2(target[sourceKey], source[sourceKey]);
|
|
147
|
+
}
|
|
135
148
|
});
|
|
136
149
|
return target;
|
|
137
150
|
}
|
package/lib/dayjs.js
CHANGED
|
@@ -42,6 +42,7 @@ module.exports = __toCommonJS(dayjs_exports);
|
|
|
42
42
|
var import_dayjs = __toESM(require("dayjs"));
|
|
43
43
|
var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat"));
|
|
44
44
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
45
|
+
var import_duration = __toESM(require("dayjs/plugin/duration"));
|
|
45
46
|
var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
|
|
46
47
|
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
47
48
|
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
@@ -66,6 +67,7 @@ import_dayjs.default.extend(import_weekOfYear.default);
|
|
|
66
67
|
import_dayjs.default.extend(import_weekYear.default);
|
|
67
68
|
import_dayjs.default.extend(import_customParseFormat.default);
|
|
68
69
|
import_dayjs.default.extend(import_advancedFormat.default);
|
|
70
|
+
import_dayjs.default.extend(import_duration.default);
|
|
69
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
72
|
0 && (module.exports = {
|
|
71
73
|
dayjs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.15",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"multer": "^1.4.5-lts.1",
|
|
17
17
|
"object-path": "^0.11.8"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "b0792740852a55981b2f23ad622faeee332cf678"
|
|
20
20
|
}
|