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