@whitesev/utils 2.9.6 → 2.9.8
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.amd.js +38 -29
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +38 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +38 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +38 -29
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +38 -29
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +38 -29
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Utils.d.ts +6 -2
- package/package.json +9 -9
- package/src/CommonUtil.ts +36 -31
- package/src/Utils.ts +7 -2
package/dist/index.system.js
CHANGED
|
@@ -315,38 +315,44 @@ System.register('Utils', [], (function (exports) {
|
|
|
315
315
|
if (target == null) {
|
|
316
316
|
target = {};
|
|
317
317
|
}
|
|
318
|
+
// 当前遍历的目标对象
|
|
319
|
+
let iteratorTarget;
|
|
318
320
|
if (isAdd) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
322
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
323
|
-
if (typeof sourceValue === "object" &&
|
|
324
|
-
sourceValue != null &&
|
|
325
|
-
sourceKeyName in target &&
|
|
326
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
327
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
328
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
332
|
-
}
|
|
321
|
+
// 追加并覆盖是以source为准
|
|
322
|
+
iteratorTarget = source;
|
|
333
323
|
}
|
|
334
324
|
else {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
325
|
+
// 覆盖以target为准
|
|
326
|
+
iteratorTarget = target;
|
|
327
|
+
}
|
|
328
|
+
for (const keyName in iteratorTarget) {
|
|
329
|
+
if (!isAdd && !(keyName in source)) {
|
|
330
|
+
// 仅替换 但是源端没有此键
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
const targetValue = Reflect.get(target, keyName);
|
|
334
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
335
|
+
if (typeof sourceValue === "object" &&
|
|
336
|
+
sourceValue != null &&
|
|
337
|
+
keyName in target &&
|
|
338
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
339
|
+
// 源端的值是object类型,且不是元素节点
|
|
340
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
341
|
+
let childObjectValue;
|
|
342
|
+
if (Array.isArray(sourceValue)) {
|
|
343
|
+
if (Array.isArray(targetValue)) {
|
|
344
|
+
targetValue.length = 0;
|
|
346
345
|
}
|
|
347
|
-
|
|
348
|
-
Reflect.set(target, targetKeyName, sourceValue);
|
|
346
|
+
childObjectValue = sourceValue;
|
|
349
347
|
}
|
|
348
|
+
else {
|
|
349
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
350
|
+
}
|
|
351
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
/* 直接赋值 */
|
|
355
|
+
Reflect.set(target, keyName, sourceValue);
|
|
350
356
|
}
|
|
351
357
|
}
|
|
352
358
|
return target;
|
|
@@ -443,6 +449,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
443
449
|
}
|
|
444
450
|
toJSON(data, errorCallBack) {
|
|
445
451
|
let result = {};
|
|
452
|
+
if (data == null) {
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
446
455
|
if (typeof data === "object") {
|
|
447
456
|
return data;
|
|
448
457
|
}
|
|
@@ -5495,7 +5504,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5495
5504
|
}
|
|
5496
5505
|
const domUtils = new DOMUtils();
|
|
5497
5506
|
|
|
5498
|
-
const version = "2.9.
|
|
5507
|
+
const version = "2.9.8";
|
|
5499
5508
|
|
|
5500
5509
|
class Utils {
|
|
5501
5510
|
windowApi;
|
|
@@ -8033,7 +8042,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8033
8042
|
}
|
|
8034
8043
|
}
|
|
8035
8044
|
/**
|
|
8036
|
-
*
|
|
8045
|
+
* 深度获取对象的某个属性
|
|
8037
8046
|
* @param target 待获取的对象
|
|
8038
8047
|
* @param handler 获取属性的回调
|
|
8039
8048
|
*/
|