@whitesev/utils 1.1.0 → 1.1.2

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
@@ -2471,7 +2471,12 @@ class LockFunction {
2471
2471
  #delayTime = 0;
2472
2472
  #callback;
2473
2473
  #context;
2474
+ lock;
2475
+ unlock;
2476
+ run;
2477
+ isLock;
2474
2478
  constructor(callback, context, delayTime) {
2479
+ let that = this;
2475
2480
  this.#callback = callback;
2476
2481
  if (typeof context === "number") {
2477
2482
  this.#delayTime = context;
@@ -2481,37 +2486,37 @@ class LockFunction {
2481
2486
  this.#delayTime = delayTime;
2482
2487
  this.#context = context;
2483
2488
  }
2484
- }
2485
- /**
2486
- * 判断是否被锁
2487
- */
2488
- isLock() {
2489
- return this.#flag;
2490
- }
2491
- /**
2492
- * 锁
2493
- */
2494
- lock() {
2495
- this.#flag = true;
2496
- }
2497
- /**
2498
- * 解锁
2499
- */
2500
- unlock() {
2501
- setTimeout(() => {
2502
- this.#flag = false;
2503
- }, this.#delayTime);
2504
- }
2505
- /**
2506
- * 执行
2507
- */
2508
- async run(...args) {
2509
- if (this.isLock()) {
2510
- return;
2511
- }
2512
- this.lock();
2513
- await this.#callback.apply(this.#context, args);
2514
- this.unlock();
2489
+ /**
2490
+ * 锁
2491
+ */
2492
+ this.lock = function () {
2493
+ that.#flag = true;
2494
+ };
2495
+ /**
2496
+ * 解锁
2497
+ */
2498
+ this.unlock = function () {
2499
+ setTimeout(() => {
2500
+ that.#flag = false;
2501
+ }, that.#delayTime);
2502
+ };
2503
+ /**
2504
+ * 判断是否被锁
2505
+ */
2506
+ this.isLock = function () {
2507
+ return that.#flag;
2508
+ };
2509
+ /**
2510
+ * 执行
2511
+ */
2512
+ this.run = async function (...args) {
2513
+ if (that.isLock()) {
2514
+ return;
2515
+ }
2516
+ that.lock();
2517
+ await that.#callback.apply(that.#context, args);
2518
+ that.unlock();
2519
+ };
2515
2520
  }
2516
2521
  }
2517
2522
 
@@ -4644,42 +4649,35 @@ class Utils {
4644
4649
  callback: () => { },
4645
4650
  config: {
4646
4651
  /**
4647
- * @type {boolean|undefined}
4648
4652
  * + true 监听以 target 为根节点的整个子树。包括子树中所有节点的属性,而不仅仅是针对 target
4649
4653
  * + false (默认) 不生效
4650
4654
  */
4651
4655
  subtree: void 0,
4652
4656
  /**
4653
- * @type {boolean|undefined}
4654
4657
  * + true 监听 target 节点中发生的节点的新增与删除(同时,如果 subtree 为 true,会针对整个子树生效)
4655
4658
  * + false (默认) 不生效
4656
4659
  */
4657
4660
  childList: void 0,
4658
4661
  /**
4659
- * @type {boolean|undefined}
4660
4662
  * + true 观察所有监听的节点属性值的变化。默认值为 true,当声明了 attributeFilter 或 attributeOldValue
4661
4663
  * + false (默认) 不生效
4662
4664
  */
4663
4665
  attributes: void 0,
4664
4666
  /**
4665
4667
  * 一个用于声明哪些属性名会被监听的数组。如果不声明该属性,所有属性的变化都将触发通知
4666
- * @type {[...string]|undefined}
4667
4668
  */
4668
4669
  attributeFilter: void 0,
4669
4670
  /**
4670
- * @type {boolean|undefined}
4671
4671
  * + true 记录上一次被监听的节点的属性变化;可查阅 MutationObserver 中的 Monitoring attribute values 了解关于观察属性变化和属性值记录的详情
4672
4672
  * + false (默认) 不生效
4673
4673
  */
4674
4674
  attributeOldValue: void 0,
4675
4675
  /**
4676
- * @type {boolean|undefined}
4677
4676
  * + true 监听声明的 target 节点上所有字符的变化。默认值为 true,如果声明了 characterDataOldValue
4678
4677
  * + false (默认) 不生效
4679
4678
  */
4680
4679
  characterData: void 0,
4681
4680
  /**
4682
- * @type {boolean|undefined}
4683
4681
  * + true 记录前一个被监听的节点中发生的文本变化
4684
4682
  * + false (默认) 不生效
4685
4683
  */
@@ -4687,11 +4685,10 @@ class Utils {
4687
4685
  },
4688
4686
  };
4689
4687
  observer_config = UtilsContext.assign(default_obverser_config, observer_config);
4690
- let MutationObserver = UtilsCore.window.MutationObserver ||
4688
+ let windowMutationObserver = window.MutationObserver ||
4691
4689
  UtilsCore.window.webkitMutationObserver ||
4692
4690
  UtilsCore.window.MozMutationObserver;
4693
- /** @type {MutationObserver} */
4694
- let mutationObserver = new MutationObserver(function (mutations, observer) {
4691
+ let mutationObserver = new windowMutationObserver(function (mutations, observer) {
4695
4692
  observer_config?.callback(mutations, observer);
4696
4693
  });
4697
4694
  if (target instanceof Node) {