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