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