@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.esm.js CHANGED
@@ -3276,14 +3276,14 @@ const TryCatch = function (...args) {
3276
3276
  };
3277
3277
 
3278
3278
  class UtilsDictionary {
3279
- #items = {};
3279
+ items = {};
3280
3280
  constructor() { }
3281
3281
  /**
3282
3282
  * 检查是否有某一个键
3283
3283
  * @param key 键
3284
3284
  */
3285
3285
  has(key) {
3286
- return this.#items.hasOwnProperty(key);
3286
+ return this.items.hasOwnProperty(key);
3287
3287
  }
3288
3288
  /**
3289
3289
  * 检查已有的键中是否以xx开头
@@ -3307,7 +3307,7 @@ class UtilsDictionary {
3307
3307
  let result = null;
3308
3308
  for (const keyName of allKeys) {
3309
3309
  if (keyName.startsWith(key)) {
3310
- result = this.#items[keyName];
3310
+ result = this.items[keyName];
3311
3311
  break;
3312
3312
  }
3313
3313
  }
@@ -3322,7 +3322,7 @@ class UtilsDictionary {
3322
3322
  if (key === void 0) {
3323
3323
  throw new Error("Utils.Dictionary().set 参数 key 不能为空");
3324
3324
  }
3325
- this.#items[key] = val;
3325
+ this.items[key] = val;
3326
3326
  }
3327
3327
  /**
3328
3328
  * 删除某一个键
@@ -3330,7 +3330,7 @@ class UtilsDictionary {
3330
3330
  */
3331
3331
  delete(key) {
3332
3332
  if (this.has(key)) {
3333
- Reflect.deleteProperty(this.#items, key);
3333
+ Reflect.deleteProperty(this.items, key);
3334
3334
  return true;
3335
3335
  }
3336
3336
  return false;
@@ -3358,8 +3358,8 @@ class UtilsDictionary {
3358
3358
  * 清空字典
3359
3359
  */
3360
3360
  clear() {
3361
- this.#items = void 0;
3362
- this.#items = {};
3361
+ this.items = void 0;
3362
+ this.items = {};
3363
3363
  }
3364
3364
  /**
3365
3365
  * 获取字典的长度
@@ -3377,14 +3377,14 @@ class UtilsDictionary {
3377
3377
  * 返回字典本身
3378
3378
  */
3379
3379
  getItems() {
3380
- return this.#items;
3380
+ return this.items;
3381
3381
  }
3382
3382
  /**
3383
3383
  * 合并另一个字典
3384
3384
  * @param data 需要合并的字典
3385
3385
  */
3386
3386
  concat(data) {
3387
- this.#items = utils.assign(this.#items, data.getItems());
3387
+ this.items = utils.assign(this.items, data.getItems());
3388
3388
  }
3389
3389
  forEach(callbackfn) {
3390
3390
  for (const key in this.getItems()) {
@@ -3461,13 +3461,20 @@ class Utils {
3461
3461
  return source;
3462
3462
  }
3463
3463
  }
3464
+ if (source == null) {
3465
+ return target;
3466
+ }
3467
+ if (target == null) {
3468
+ target = {};
3469
+ }
3464
3470
  if (isAdd) {
3465
3471
  for (const sourceKeyName in source) {
3466
3472
  const targetKeyName = sourceKeyName;
3467
3473
  let targetValue = target[targetKeyName];
3468
3474
  let sourceValue = source[sourceKeyName];
3469
- if (sourceKeyName in target &&
3470
- typeof sourceValue === "object" &&
3475
+ if (typeof sourceValue === "object" &&
3476
+ sourceValue != null &&
3477
+ sourceKeyName in target &&
3471
3478
  !UtilsContext.isDOM(sourceValue)) {
3472
3479
  /* 源端的值是object类型,且不是元素节点 */
3473
3480
  target[sourceKeyName] = UtilsContext.assign(targetValue, sourceValue, isAdd);
@@ -3482,6 +3489,7 @@ class Utils {
3482
3489
  let targetValue = target[targetKeyName];
3483
3490
  let sourceValue = source[targetKeyName];
3484
3491
  if (typeof sourceValue === "object" &&
3492
+ sourceValue != null &&
3485
3493
  !UtilsContext.isDOM(sourceValue) &&
3486
3494
  Object.keys(sourceValue).length) {
3487
3495
  /* 源端的值是object类型,且不是元素节点 */