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