@whitesev/utils 1.1.1 → 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
@@ -2482,6 +2482,7 @@
2482
2482
  run;
2483
2483
  isLock;
2484
2484
  constructor(callback, context, delayTime) {
2485
+ let that = this;
2485
2486
  this.#callback = callback;
2486
2487
  if (typeof context === "number") {
2487
2488
  this.#delayTime = context;
@@ -2495,32 +2496,32 @@
2495
2496
  * 锁
2496
2497
  */
2497
2498
  this.lock = function () {
2498
- this.#flag = true;
2499
+ that.#flag = true;
2499
2500
  };
2500
2501
  /**
2501
2502
  * 解锁
2502
2503
  */
2503
2504
  this.unlock = function () {
2504
2505
  setTimeout(() => {
2505
- this.#flag = false;
2506
- }, this.#delayTime);
2506
+ that.#flag = false;
2507
+ }, that.#delayTime);
2507
2508
  };
2508
2509
  /**
2509
2510
  * 判断是否被锁
2510
2511
  */
2511
2512
  this.isLock = function () {
2512
- return this.#flag;
2513
+ return that.#flag;
2513
2514
  };
2514
2515
  /**
2515
2516
  * 执行
2516
2517
  */
2517
2518
  this.run = async function (...args) {
2518
- if (this.isLock()) {
2519
+ if (that.isLock()) {
2519
2520
  return;
2520
2521
  }
2521
- this.lock();
2522
- await this.#callback.apply(this.#context, args);
2523
- this.unlock();
2522
+ that.lock();
2523
+ await that.#callback.apply(that.#context, args);
2524
+ that.unlock();
2524
2525
  };
2525
2526
  }
2526
2527
  }