@whitesev/utils 1.1.1 → 1.1.3
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 +18 -20
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +18 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +18 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +18 -20
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +18 -20
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +18 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/src/ColorConversion.d.ts +0 -1
- package/dist/src/GBKEncoder.d.ts +1 -1
- package/package.json +1 -1
- package/src/ColorConversion.ts +0 -1
- package/src/GBKEncoder.ts +16 -14
- package/src/LockFunction.ts +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
class ColorConversion {
|
|
4
|
-
constructor() { }
|
|
5
4
|
/**
|
|
6
5
|
* 判断是否是16进制颜色
|
|
7
6
|
* @param str
|
|
@@ -197,25 +196,23 @@ class GBKEncoder {
|
|
|
197
196
|
}
|
|
198
197
|
/**
|
|
199
198
|
* 解码
|
|
200
|
-
* @param
|
|
199
|
+
* @param str
|
|
201
200
|
*/
|
|
202
201
|
decode(str) {
|
|
203
202
|
var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
204
203
|
var UTFMatcher = /%[0-9A-F]{2}/;
|
|
205
|
-
var
|
|
204
|
+
var utf = true;
|
|
205
|
+
let that = this;
|
|
206
206
|
while (utf) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (gbk && gbk in G2Uhash) {
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
str = str.replace(gbk, String.fromCharCode("0x" + G2Uhash[gbk]));
|
|
207
|
+
let gbkMatch = str.match(GBKMatcher);
|
|
208
|
+
let utfMatch = str.match(UTFMatcher);
|
|
209
|
+
utf = Boolean(utfMatch);
|
|
210
|
+
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
211
|
+
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
215
212
|
}
|
|
216
213
|
else {
|
|
217
214
|
// @ts-ignore
|
|
218
|
-
str = str.replace(
|
|
215
|
+
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
219
216
|
}
|
|
220
217
|
}
|
|
221
218
|
return str;
|
|
@@ -2478,6 +2475,7 @@ class LockFunction {
|
|
|
2478
2475
|
run;
|
|
2479
2476
|
isLock;
|
|
2480
2477
|
constructor(callback, context, delayTime) {
|
|
2478
|
+
let that = this;
|
|
2481
2479
|
this.#callback = callback;
|
|
2482
2480
|
if (typeof context === "number") {
|
|
2483
2481
|
this.#delayTime = context;
|
|
@@ -2491,32 +2489,32 @@ class LockFunction {
|
|
|
2491
2489
|
* 锁
|
|
2492
2490
|
*/
|
|
2493
2491
|
this.lock = function () {
|
|
2494
|
-
|
|
2492
|
+
that.#flag = true;
|
|
2495
2493
|
};
|
|
2496
2494
|
/**
|
|
2497
2495
|
* 解锁
|
|
2498
2496
|
*/
|
|
2499
2497
|
this.unlock = function () {
|
|
2500
2498
|
setTimeout(() => {
|
|
2501
|
-
|
|
2502
|
-
},
|
|
2499
|
+
that.#flag = false;
|
|
2500
|
+
}, that.#delayTime);
|
|
2503
2501
|
};
|
|
2504
2502
|
/**
|
|
2505
2503
|
* 判断是否被锁
|
|
2506
2504
|
*/
|
|
2507
2505
|
this.isLock = function () {
|
|
2508
|
-
return
|
|
2506
|
+
return that.#flag;
|
|
2509
2507
|
};
|
|
2510
2508
|
/**
|
|
2511
2509
|
* 执行
|
|
2512
2510
|
*/
|
|
2513
2511
|
this.run = async function (...args) {
|
|
2514
|
-
if (
|
|
2512
|
+
if (that.isLock()) {
|
|
2515
2513
|
return;
|
|
2516
2514
|
}
|
|
2517
|
-
|
|
2518
|
-
await
|
|
2519
|
-
|
|
2515
|
+
that.lock();
|
|
2516
|
+
await that.#callback.apply(that.#context, args);
|
|
2517
|
+
that.unlock();
|
|
2520
2518
|
};
|
|
2521
2519
|
}
|
|
2522
2520
|
}
|