@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.
@@ -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 {string} str
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 gbk = true, utf = true;
207
+ var utf = true;
208
+ let that = this;
209
209
  while (utf) {
210
- // @ts-ignore
211
- gbk = str.match(GBKMatcher);
212
- // @ts-ignore
213
- utf = str.match(UTFMatcher);
214
- // @ts-ignore
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(utf, decodeURIComponent(utf));
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
- this.#flag = true;
2495
+ that.#flag = true;
2498
2496
  };
2499
2497
  /**
2500
2498
  * 解锁
2501
2499
  */
2502
2500
  this.unlock = function () {
2503
2501
  setTimeout(() => {
2504
- this.#flag = false;
2505
- }, this.#delayTime);
2502
+ that.#flag = false;
2503
+ }, that.#delayTime);
2506
2504
  };
2507
2505
  /**
2508
2506
  * 判断是否被锁
2509
2507
  */
2510
2508
  this.isLock = function () {
2511
- return this.#flag;
2509
+ return that.#flag;
2512
2510
  };
2513
2511
  /**
2514
2512
  * 执行
2515
2513
  */
2516
2514
  this.run = async function (...args) {
2517
- if (this.isLock()) {
2515
+ if (that.isLock()) {
2518
2516
  return;
2519
2517
  }
2520
- this.lock();
2521
- await this.#callback.apply(this.#context, args);
2522
- this.unlock();
2518
+ that.lock();
2519
+ await that.#callback.apply(that.#context, args);
2520
+ that.unlock();
2523
2521
  };
2524
2522
  }
2525
2523
  }