@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.esm.js CHANGED
@@ -2476,6 +2476,7 @@ class LockFunction {
2476
2476
  run;
2477
2477
  isLock;
2478
2478
  constructor(callback, context, delayTime) {
2479
+ let that = this;
2479
2480
  this.#callback = callback;
2480
2481
  if (typeof context === "number") {
2481
2482
  this.#delayTime = context;
@@ -2489,32 +2490,32 @@ class LockFunction {
2489
2490
  * 锁
2490
2491
  */
2491
2492
  this.lock = function () {
2492
- this.#flag = true;
2493
+ that.#flag = true;
2493
2494
  };
2494
2495
  /**
2495
2496
  * 解锁
2496
2497
  */
2497
2498
  this.unlock = function () {
2498
2499
  setTimeout(() => {
2499
- this.#flag = false;
2500
- }, this.#delayTime);
2500
+ that.#flag = false;
2501
+ }, that.#delayTime);
2501
2502
  };
2502
2503
  /**
2503
2504
  * 判断是否被锁
2504
2505
  */
2505
2506
  this.isLock = function () {
2506
- return this.#flag;
2507
+ return that.#flag;
2507
2508
  };
2508
2509
  /**
2509
2510
  * 执行
2510
2511
  */
2511
2512
  this.run = async function (...args) {
2512
- if (this.isLock()) {
2513
+ if (that.isLock()) {
2513
2514
  return;
2514
2515
  }
2515
- this.lock();
2516
- await this.#callback.apply(this.#context, args);
2517
- this.unlock();
2516
+ that.lock();
2517
+ await that.#callback.apply(that.#context, args);
2518
+ that.unlock();
2518
2519
  };
2519
2520
  }
2520
2521
  }