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