@whitesev/utils 1.1.2 → 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 CHANGED
@@ -1,7 +1,6 @@
1
1
  define((function () { 'use strict';
2
2
 
3
3
  class ColorConversion {
4
- constructor() { }
5
4
  /**
6
5
  * 判断是否是16进制颜色
7
6
  * @param str
@@ -197,25 +196,23 @@ define((function () { 'use strict';
197
196
  }
198
197
  /**
199
198
  * 解码
200
- * @param {string} str
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 gbk = true, utf = true;
204
+ var utf = true;
205
+ let that = this;
206
206
  while (utf) {
207
- // @ts-ignore
208
- gbk = str.match(GBKMatcher);
209
- // @ts-ignore
210
- utf = str.match(UTFMatcher);
211
- // @ts-ignore
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(utf, decodeURIComponent(utf));
215
+ str = str.replace(utfMatch, decodeURIComponent(utfMatch));
219
216
  }
220
217
  }
221
218
  return str;