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