@whitesev/utils 1.5.9 → 1.6.1
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 +19 -11
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +19 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +19 -11
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +19 -11
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +19 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Dictionary.d.ts +1 -1
- package/package.json +1 -1
- package/src/Dictionary.ts +9 -9
- package/src/Utils.ts +9 -1
package/dist/index.amd.js
CHANGED
|
@@ -3278,14 +3278,14 @@ define((function () { 'use strict';
|
|
|
3278
3278
|
};
|
|
3279
3279
|
|
|
3280
3280
|
class UtilsDictionary {
|
|
3281
|
-
|
|
3281
|
+
items = {};
|
|
3282
3282
|
constructor() { }
|
|
3283
3283
|
/**
|
|
3284
3284
|
* 检查是否有某一个键
|
|
3285
3285
|
* @param key 键
|
|
3286
3286
|
*/
|
|
3287
3287
|
has(key) {
|
|
3288
|
-
return this
|
|
3288
|
+
return this.items.hasOwnProperty(key);
|
|
3289
3289
|
}
|
|
3290
3290
|
/**
|
|
3291
3291
|
* 检查已有的键中是否以xx开头
|
|
@@ -3309,7 +3309,7 @@ define((function () { 'use strict';
|
|
|
3309
3309
|
let result = null;
|
|
3310
3310
|
for (const keyName of allKeys) {
|
|
3311
3311
|
if (keyName.startsWith(key)) {
|
|
3312
|
-
result = this
|
|
3312
|
+
result = this.items[keyName];
|
|
3313
3313
|
break;
|
|
3314
3314
|
}
|
|
3315
3315
|
}
|
|
@@ -3324,7 +3324,7 @@ define((function () { 'use strict';
|
|
|
3324
3324
|
if (key === void 0) {
|
|
3325
3325
|
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
3326
3326
|
}
|
|
3327
|
-
this
|
|
3327
|
+
this.items[key] = val;
|
|
3328
3328
|
}
|
|
3329
3329
|
/**
|
|
3330
3330
|
* 删除某一个键
|
|
@@ -3332,7 +3332,7 @@ define((function () { 'use strict';
|
|
|
3332
3332
|
*/
|
|
3333
3333
|
delete(key) {
|
|
3334
3334
|
if (this.has(key)) {
|
|
3335
|
-
Reflect.deleteProperty(this
|
|
3335
|
+
Reflect.deleteProperty(this.items, key);
|
|
3336
3336
|
return true;
|
|
3337
3337
|
}
|
|
3338
3338
|
return false;
|
|
@@ -3360,8 +3360,8 @@ define((function () { 'use strict';
|
|
|
3360
3360
|
* 清空字典
|
|
3361
3361
|
*/
|
|
3362
3362
|
clear() {
|
|
3363
|
-
this
|
|
3364
|
-
this
|
|
3363
|
+
this.items = void 0;
|
|
3364
|
+
this.items = {};
|
|
3365
3365
|
}
|
|
3366
3366
|
/**
|
|
3367
3367
|
* 获取字典的长度
|
|
@@ -3379,14 +3379,14 @@ define((function () { 'use strict';
|
|
|
3379
3379
|
* 返回字典本身
|
|
3380
3380
|
*/
|
|
3381
3381
|
getItems() {
|
|
3382
|
-
return this
|
|
3382
|
+
return this.items;
|
|
3383
3383
|
}
|
|
3384
3384
|
/**
|
|
3385
3385
|
* 合并另一个字典
|
|
3386
3386
|
* @param data 需要合并的字典
|
|
3387
3387
|
*/
|
|
3388
3388
|
concat(data) {
|
|
3389
|
-
this
|
|
3389
|
+
this.items = utils.assign(this.items, data.getItems());
|
|
3390
3390
|
}
|
|
3391
3391
|
forEach(callbackfn) {
|
|
3392
3392
|
for (const key in this.getItems()) {
|
|
@@ -3463,13 +3463,20 @@ define((function () { 'use strict';
|
|
|
3463
3463
|
return source;
|
|
3464
3464
|
}
|
|
3465
3465
|
}
|
|
3466
|
+
if (source == null) {
|
|
3467
|
+
return target;
|
|
3468
|
+
}
|
|
3469
|
+
if (target == null) {
|
|
3470
|
+
target = {};
|
|
3471
|
+
}
|
|
3466
3472
|
if (isAdd) {
|
|
3467
3473
|
for (const sourceKeyName in source) {
|
|
3468
3474
|
const targetKeyName = sourceKeyName;
|
|
3469
3475
|
let targetValue = target[targetKeyName];
|
|
3470
3476
|
let sourceValue = source[sourceKeyName];
|
|
3471
|
-
if (
|
|
3472
|
-
|
|
3477
|
+
if (typeof sourceValue === "object" &&
|
|
3478
|
+
sourceValue != null &&
|
|
3479
|
+
sourceKeyName in target &&
|
|
3473
3480
|
!UtilsContext.isDOM(sourceValue)) {
|
|
3474
3481
|
/* 源端的值是object类型,且不是元素节点 */
|
|
3475
3482
|
target[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
@@ -3484,6 +3491,7 @@ define((function () { 'use strict';
|
|
|
3484
3491
|
let targetValue = target[targetKeyName];
|
|
3485
3492
|
let sourceValue = source[targetKeyName];
|
|
3486
3493
|
if (typeof sourceValue === "object" &&
|
|
3494
|
+
sourceValue != null &&
|
|
3487
3495
|
!UtilsContext.isDOM(sourceValue) &&
|
|
3488
3496
|
Object.keys(sourceValue).length) {
|
|
3489
3497
|
/* 源端的值是object类型,且不是元素节点 */
|