@whitesev/utils 1.5.9 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
package/src/Utils.ts CHANGED
@@ -119,14 +119,21 @@ class Utils {
119
119
  return source;
120
120
  }
121
121
  }
122
+ if (source == null) {
123
+ return target;
124
+ }
125
+ if (target == null) {
126
+ target = {};
127
+ }
122
128
  if (isAdd) {
123
129
  for (const sourceKeyName in source) {
124
130
  const targetKeyName = sourceKeyName;
125
131
  let targetValue = (target as any)[targetKeyName];
126
132
  let sourceValue = (source as any)[sourceKeyName];
127
133
  if (
128
- sourceKeyName in target &&
129
134
  typeof sourceValue === "object" &&
135
+ sourceValue != null &&
136
+ sourceKeyName in target &&
130
137
  !UtilsContext.isDOM(sourceValue)
131
138
  ) {
132
139
  /* 源端的值是object类型,且不是元素节点 */
@@ -146,6 +153,7 @@ class Utils {
146
153
  let sourceValue = (source as any)[targetKeyName];
147
154
  if (
148
155
  typeof sourceValue === "object" &&
156
+ sourceValue != null &&
149
157
  !UtilsContext.isDOM(sourceValue) &&
150
158
  Object.keys(sourceValue).length
151
159
  ) {