@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.amd.js +9 -8
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +9 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +9 -8
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +9 -8
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +9 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/LockFunction.ts +9 -9
package/dist/index.amd.js
CHANGED
|
@@ -2478,6 +2478,7 @@ define((function () { 'use strict';
|
|
|
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 @@ define((function () { 'use strict';
|
|
|
2491
2492
|
* 锁
|
|
2492
2493
|
*/
|
|
2493
2494
|
this.lock = function () {
|
|
2494
|
-
|
|
2495
|
+
that.#flag = true;
|
|
2495
2496
|
};
|
|
2496
2497
|
/**
|
|
2497
2498
|
* 解锁
|
|
2498
2499
|
*/
|
|
2499
2500
|
this.unlock = function () {
|
|
2500
2501
|
setTimeout(() => {
|
|
2501
|
-
|
|
2502
|
-
},
|
|
2502
|
+
that.#flag = false;
|
|
2503
|
+
}, that.#delayTime);
|
|
2503
2504
|
};
|
|
2504
2505
|
/**
|
|
2505
2506
|
* 判断是否被锁
|
|
2506
2507
|
*/
|
|
2507
2508
|
this.isLock = function () {
|
|
2508
|
-
return
|
|
2509
|
+
return that.#flag;
|
|
2509
2510
|
};
|
|
2510
2511
|
/**
|
|
2511
2512
|
* 执行
|
|
2512
2513
|
*/
|
|
2513
2514
|
this.run = async function (...args) {
|
|
2514
|
-
if (
|
|
2515
|
+
if (that.isLock()) {
|
|
2515
2516
|
return;
|
|
2516
2517
|
}
|
|
2517
|
-
|
|
2518
|
-
await
|
|
2519
|
-
|
|
2518
|
+
that.lock();
|
|
2519
|
+
await that.#callback.apply(that.#context, args);
|
|
2520
|
+
that.unlock();
|
|
2520
2521
|
};
|
|
2521
2522
|
}
|
|
2522
2523
|
}
|