light-h5-core-lib 2.10.6 → 2.10.7

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.
@@ -5,23 +5,21 @@ exports.DateUtil = void 0;
5
5
  * 日期(时间)工具
6
6
  * @author aonaufly
7
7
  */
8
- var DateUtil = /** @class */ (function () {
9
- function DateUtil() {
10
- }
8
+ class DateUtil {
11
9
  /**
12
10
  * 获取指定时间的时间戳 (单位:ms)
13
11
  * @param date 如: "2020-3-14 11:30:30"
14
12
  */
15
- DateUtil.getTargetTimeStamp = function (date) {
13
+ static getTargetTimeStamp(date) {
16
14
  return new Date(date).getTime();
17
- };
15
+ }
18
16
  /**
19
17
  * 获取指定时间的时间秒 (单位:s)
20
18
  * @param date 如: "2020-3-14 11:30:30"
21
19
  */
22
- DateUtil.getTargetSeconds = function (date) {
20
+ static getTargetSeconds(date) {
23
21
  return Math.floor(DateUtil.getTargetTimeStamp(date) / 1000);
24
- };
22
+ }
25
23
  /**
26
24
  * 格式化时间(时,分,秒)<b style="color:red">使用 separator分割</b>
27
25
  * @param s 秒
@@ -29,47 +27,42 @@ var DateUtil = /** @class */ (function () {
29
27
  * @param isSingle0 是否补0(default:true)
30
28
  * @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
31
29
  */
32
- DateUtil.format_HMS = function (s, separator, isSingle0, isDiscardH) {
33
- if (separator === void 0) { separator = ":"; }
34
- if (isSingle0 === void 0) { isSingle0 = true; }
35
- if (isDiscardH === void 0) { isDiscardH = false; }
36
- var h = Math.floor(s / 3600);
30
+ static format_HMS(s, separator = ":", isSingle0 = true, isDiscardH = false) {
31
+ const h = Math.floor(s / 3600);
37
32
  if (isDiscardH && h == 0) {
38
33
  return DateUtil.format_MS(s, separator, isSingle0);
39
34
  }
40
- var m = Math.floor((s - h * 3600) / 60);
35
+ const m = Math.floor((s - h * 3600) / 60);
41
36
  s = s - h * 3600 - m * 60;
42
- var result = isSingle0 ? (h < 10 ? "0".concat(h) : h.toString()) : h.toString();
37
+ let result = isSingle0 ? (h < 10 ? `0${h}` : h.toString()) : h.toString();
43
38
  result += separator;
44
- result = result + (isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString());
39
+ result = result + (isSingle0 ? (m < 10 ? `0${m}` : m.toString()) : m.toString());
45
40
  result += separator;
46
- result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
41
+ result = result + (isSingle0 ? (s < 10 ? `0${s}` : s.toString()) : s.toString());
47
42
  return result;
48
- };
43
+ }
49
44
  /**
50
45
  * 格式化时间(分,秒)
51
46
  * @param s 秒
52
47
  * @param separator 分隔符(default: ":")
53
48
  * @param isSingle0 是否补0(default:true)
54
49
  */
55
- DateUtil.format_MS = function (s, separator, isSingle0) {
56
- if (separator === void 0) { separator = ":"; }
57
- if (isSingle0 === void 0) { isSingle0 = true; }
58
- var m = Math.floor(s / 60);
50
+ static format_MS(s, separator = ":", isSingle0 = true) {
51
+ const m = Math.floor(s / 60);
59
52
  s = s - m * 60;
60
- var result = isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString();
53
+ let result = isSingle0 ? (m < 10 ? `0${m}` : m.toString()) : m.toString();
61
54
  result += separator;
62
- result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
55
+ result = result + (isSingle0 ? (s < 10 ? `0${s}` : s.toString()) : s.toString());
63
56
  return result;
64
- };
57
+ }
65
58
  /**
66
59
  * 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计<b style="color:red">当天时间24:00</b>
67
60
  * @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
68
61
  * @return 下一天的时间Second
69
62
  * */
70
- DateUtil.getNextDayTimeStamp = function (nowSecond) {
63
+ static getNextDayTimeStamp(nowSecond) {
71
64
  return DateUtil.getTodayAppointTimeStamp(nowSecond, 23, 59, 59, 999);
72
- };
65
+ }
73
66
  /**
74
67
  * 获取今日指定的时间(秒), 例如今日20:00
75
68
  * @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
@@ -78,39 +71,32 @@ var DateUtil = /** @class */ (function () {
78
71
  * @param second 指定的秒数 0~59
79
72
  * @param millisecond 指定的毫秒数 0~999
80
73
  */
81
- DateUtil.getTodayAppointTimeStamp = function (nowSecond, hour, minute, second, millisecond) {
82
- if (minute === void 0) { minute = 0; }
83
- if (second === void 0) { second = 0; }
84
- if (millisecond === void 0) { millisecond = 0; }
74
+ static getTodayAppointTimeStamp(nowSecond, hour, minute = 0, second = 0, millisecond = 0) {
85
75
  return Math.ceil(new Date(new Date(nowSecond * 1000).setHours(hour, minute, second, millisecond)).getTime() / 1000);
86
- };
76
+ }
87
77
  /**
88
78
  * 获得剩余的过期时间秒(S)用于倒计时
89
79
  * @param targetExpireSecond 过期的时间戳(s)
90
80
  * @param curSecond 当前时间戳(s)
91
81
  * @param offsetSecond 误差值(s) (targetExpireSecond + offsetSecond)用于延长/缩短一些过期时间
92
82
  */
93
- DateUtil.getRemainingSecond = function (targetExpireSecond, curSecond, offsetSecond) {
94
- if (curSecond === void 0) { curSecond = null; }
95
- if (offsetSecond === void 0) { offsetSecond = 1; }
83
+ static getRemainingSecond(targetExpireSecond, curSecond = null, offsetSecond = 1) {
96
84
  if (curSecond == null) {
97
85
  curSecond = Math.floor(Date.now() / 1000);
98
86
  }
99
87
  return targetExpireSecond + offsetSecond - curSecond;
100
- };
88
+ }
101
89
  /**
102
90
  * 获得过期的时间戳(S)
103
91
  * @param durationSecond 过期的时间倒计时(s)
104
92
  * @param curSecond 当前的时间(s)
105
93
  * @return 过期的时间戳(s)
106
94
  */
107
- DateUtil.getExpireSecond = function (durationSecond, curSecond) {
108
- if (curSecond === void 0) { curSecond = null; }
95
+ static getExpireSecond(durationSecond, curSecond = null) {
109
96
  if (curSecond == null) {
110
97
  curSecond = Math.floor(Date.now() / 1000);
111
98
  }
112
99
  return curSecond + durationSecond;
113
- };
114
- return DateUtil;
115
- }());
100
+ }
101
+ }
116
102
  exports.DateUtil = DateUtil;
@@ -5,29 +5,26 @@ exports.FloatDigitUtil = void 0;
5
5
  * Float精度
6
6
  * @author aonaufly
7
7
  */
8
- var FloatDigitUtil = /** @class */ (function () {
9
- function FloatDigitUtil() {
10
- }
8
+ class FloatDigitUtil {
11
9
  /**
12
10
  * 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
13
11
  * @param fNum 小数
14
12
  * @param digit 精度
15
13
  */
16
- FloatDigitUtil.formatFloat = function (fNum, digit) {
17
- var m = Math.pow(10, digit);
14
+ static formatFloat(fNum, digit) {
15
+ let m = Math.pow(10, digit);
18
16
  return parseInt((fNum * m).toString(), 10) / m;
19
- };
17
+ }
20
18
  //#region 小数格式化
21
19
  /**
22
20
  * 小数的格式化
23
21
  */
24
- FloatDigitUtil.formatDecimalNumber = function (num, factor, isRound) {
25
- if (isRound === void 0) { isRound = true; }
22
+ static formatDecimalNumber(num, factor, isRound = true) {
26
23
  if (factor <= 0) {
27
24
  return null;
28
25
  }
29
- var factorX = Math.pow(10, factor);
30
- var value;
26
+ let factorX = Math.pow(10, factor);
27
+ let value;
31
28
  if (isRound) {
32
29
  value = Math.round(num * factorX) / factorX;
33
30
  }
@@ -35,18 +32,16 @@ var FloatDigitUtil = /** @class */ (function () {
35
32
  value = Math.trunc(num * factorX) / factorX;
36
33
  }
37
34
  return value;
38
- };
35
+ }
39
36
  /**
40
37
  * 小数的格式化
41
38
  */
42
- FloatDigitUtil.formatDecimalString = function (num, factor, isRound, isSupplementZero) {
43
- if (isRound === void 0) { isRound = true; }
44
- if (isSupplementZero === void 0) { isSupplementZero = true; }
39
+ static formatDecimalString(num, factor, isRound = true, isSupplementZero = true) {
45
40
  if (factor <= 0) {
46
41
  return null;
47
42
  }
48
- var factorX = Math.pow(10, factor);
49
- var value;
43
+ let factorX = Math.pow(10, factor);
44
+ let value;
50
45
  if (isRound) {
51
46
  value = Math.round(num * factorX) / factorX;
52
47
  }
@@ -56,8 +51,7 @@ var FloatDigitUtil = /** @class */ (function () {
56
51
  if (isSupplementZero) {
57
52
  return value.toFixed(factor);
58
53
  }
59
- return "".concat(value);
60
- };
61
- return FloatDigitUtil;
62
- }());
54
+ return `${value}`;
55
+ }
56
+ }
63
57
  exports.FloatDigitUtil = FloatDigitUtil;
@@ -5,15 +5,13 @@ exports.GetDecorateUtils = void 0;
5
5
  * 获取装饰的相关参数
6
6
  * @author Aonaufly
7
7
  */
8
- var GetDecorateUtils = /** @class */ (function () {
9
- function GetDecorateUtils() {
10
- }
8
+ class GetDecorateUtils {
11
9
  /**
12
10
  * 获取类中成员
13
11
  * @param obj
14
12
  * @param memberName 成员名称
15
13
  */
16
- GetDecorateUtils.getObjMember = function (obj, memberName) {
14
+ static getObjMember(obj, memberName) {
17
15
  if (!obj)
18
16
  return null;
19
17
  if (obj[memberName]) {
@@ -26,14 +24,14 @@ var GetDecorateUtils = /** @class */ (function () {
26
24
  return obj["prototype"][memberName];
27
25
  }
28
26
  return null;
29
- };
27
+ }
30
28
  /**
31
29
  * 绑定方法
32
30
  * @param classObj
33
31
  * @param funName
34
32
  * @param fun
35
33
  */
36
- GetDecorateUtils.bindFun = function (classObj, funName, fun) {
34
+ static bindFun(classObj, funName, fun) {
37
35
  if (classObj[funName] != null) {
38
36
  classObj[funName] = fun.bind(classObj);
39
37
  }
@@ -44,16 +42,16 @@ var GetDecorateUtils = /** @class */ (function () {
44
42
  classObj["prototype"][funName] = fun.bind(classObj);
45
43
  }
46
44
  else {
47
- console.warn("".concat(funName, " \u7ED1\u5B9A\u65B9\u6CD5\u5931\u8D25!"));
45
+ console.warn(`${funName} 绑定方法失败!`);
48
46
  }
49
- };
47
+ }
50
48
  /**
51
49
  * 设置字段/属性的值
52
50
  * @param classObj
53
51
  * @param fieldName
54
52
  * @param value
55
53
  */
56
- GetDecorateUtils.setFieldValue = function (classObj, fieldName, value) {
54
+ static setFieldValue(classObj, fieldName, value) {
57
55
  if (classObj[fieldName] != null) {
58
56
  classObj[fieldName] = value;
59
57
  return true;
@@ -67,7 +65,6 @@ var GetDecorateUtils = /** @class */ (function () {
67
65
  return true;
68
66
  }
69
67
  return false;
70
- };
71
- return GetDecorateUtils;
72
- }());
68
+ }
69
+ }
73
70
  exports.GetDecorateUtils = GetDecorateUtils;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapUtil = void 0;
4
+ /**
5
+ * Map工具
6
+ * @author Aonaufly
7
+ */
8
+ class MapUtil {
9
+ /**
10
+ * 遍历Map中的所有元素<b style="color:red">每次执行everyCallback</b>
11
+ * @param targetMap 目标Map
12
+ * @param everyCallback 每次的回调
13
+ */
14
+ static all(targetMap, everyCallback) {
15
+ if (!targetMap || targetMap.size <= 0) {
16
+ return;
17
+ }
18
+ if (!everyCallback)
19
+ return;
20
+ const keys = targetMap.keys();
21
+ let keyItems = keys.next();
22
+ while (!keyItems.done) {
23
+ everyCallback(keyItems.value, targetMap.get(keyItems.value));
24
+ keyItems = keys.next();
25
+ }
26
+ }
27
+ }
28
+ exports.MapUtil = MapUtil;
@@ -5,19 +5,15 @@ exports.NumberUtil = void 0;
5
5
  * 数值类型处理
6
6
  * @author Aonaufly
7
7
  */
8
- var NumberUtil = /** @class */ (function () {
9
- function NumberUtil() {
10
- }
8
+ class NumberUtil {
11
9
  /**
12
10
  * 获得Proto中的数字
13
11
  */
14
- NumberUtil.getProtoNum = function (data, key, defaultValue) {
15
- if (defaultValue === void 0) { defaultValue = 0; }
12
+ static getProtoNum(data, key, defaultValue = 0) {
16
13
  if (key in data) {
17
14
  return data[key];
18
15
  }
19
16
  return defaultValue;
20
- };
21
- return NumberUtil;
22
- }());
17
+ }
18
+ }
23
19
  exports.NumberUtil = NumberUtil;
@@ -1,102 +1,59 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.PromiseUtil = void 0;
40
4
  /**
41
5
  * 异步处理工具
42
6
  * @author Aonaufly
43
7
  */
44
- var PromiseUtil = /** @class */ (function () {
45
- function PromiseUtil() {
46
- }
8
+ class PromiseUtil {
47
9
  /**
48
10
  * 执行所有异步并返回数据<br>
49
11
  * <div style="color: #FF0000;">⚠️:参数为异步方法数组,封装了异步方法的执行</div>
50
12
  */
51
- PromiseUtil.all = function (promiseArr) {
52
- return __awaiter(this, void 0, void 0, function () {
53
- return __generator(this, function (_a) {
54
- return [2 /*return*/, new Promise(function (resolve, reject) {
55
- if (!promiseArr || promiseArr.length == 0) {
56
- resolve(new Error('promiseArr is null'));
57
- return;
13
+ static async all(promiseArr) {
14
+ return new Promise((resolve, reject) => {
15
+ if (!promiseArr || promiseArr.length == 0) {
16
+ resolve(new Error('promiseArr is null'));
17
+ return;
18
+ }
19
+ const execAsync = (isFunc) => {
20
+ let arr = [];
21
+ if (isFunc) {
22
+ const promiseFuncs = promiseArr.slice(0);
23
+ for (let i = 0; i < promiseFuncs.length; i++) {
24
+ arr.push(promiseFuncs[i]());
25
+ }
26
+ }
27
+ else {
28
+ const promiseObjects = promiseArr.slice(0);
29
+ let item;
30
+ for (let i = 0; i < promiseObjects.length; i++) {
31
+ item = promiseObjects[i];
32
+ if (item.params && item.params.length > 0) {
33
+ arr.push(item.asyncFunc(...item.params));
58
34
  }
59
- var execAsync = function (isFunc) {
60
- var arr = [];
61
- if (isFunc) {
62
- var promiseFuncs = promiseArr.slice(0);
63
- for (var i = 0; i < promiseFuncs.length; i++) {
64
- arr.push(promiseFuncs[i]());
65
- }
66
- }
67
- else {
68
- var promiseObjects = promiseArr.slice(0);
69
- var item = void 0;
70
- for (var i = 0; i < promiseObjects.length; i++) {
71
- item = promiseObjects[i];
72
- if (item.params && item.params.length > 0) {
73
- arr.push(item.asyncFunc.apply(item, item.params));
74
- }
75
- else {
76
- arr.push(item.asyncFunc());
77
- }
78
- }
79
- }
80
- return arr;
81
- };
82
- var allPromises = execAsync(promiseArr[0] instanceof Function);
83
- Promise.all(allPromises).then(function (promiseResult) {
84
- resolve(promiseResult);
85
- }).catch(function (e) { return reject(e); });
86
- })];
87
- });
35
+ else {
36
+ arr.push(item.asyncFunc());
37
+ }
38
+ }
39
+ }
40
+ return arr;
41
+ };
42
+ let allPromises = execAsync(promiseArr[0] instanceof Function);
43
+ Promise.all(allPromises).then((promiseResult) => {
44
+ resolve(promiseResult);
45
+ }).catch(e => reject(e));
88
46
  });
89
- };
47
+ }
90
48
  /**
91
49
  * 拼接带参数的异步列表
92
50
  */
93
- PromiseUtil.spliceExistParamsAsyncFuncList = function (funcList, params) {
94
- var arr = [];
95
- for (var i = 0; i < funcList.length; i++) {
51
+ static spliceExistParamsAsyncFuncList(funcList, params) {
52
+ let arr = [];
53
+ for (let i = 0; i < funcList.length; i++) {
96
54
  arr.push({ asyncFunc: funcList[i], params: params[i] });
97
55
  }
98
56
  return arr;
99
- };
100
- return PromiseUtil;
101
- }());
57
+ }
58
+ }
102
59
  exports.PromiseUtil = PromiseUtil;
@@ -5,9 +5,7 @@ exports.RandomNumUtil = void 0;
5
5
  * 随机数生成工具
6
6
  * @author aonaufly
7
7
  */
8
- var RandomNumUtil = /** @class */ (function () {
9
- function RandomNumUtil() {
10
- }
8
+ class RandomNumUtil {
11
9
  /**
12
10
  * 获取一定范围的随机整数
13
11
  *
@@ -17,12 +15,11 @@ var RandomNumUtil = /** @class */ (function () {
17
15
  * @param max 最大数
18
16
  * @param isInt 是否返回整数
19
17
  */
20
- RandomNumUtil.randomNumBoth = function (min, max, isInt) {
21
- if (isInt === void 0) { isInt = true; }
22
- var Range = max - min;
18
+ static randomNumBoth(min, max, isInt = true) {
19
+ const Range = max - min;
23
20
  if (Range > 0.0) {
24
- var Rand = Math.random();
25
- var num = void 0;
21
+ const Rand = Math.random();
22
+ let num;
26
23
  if (isInt) {
27
24
  num = min + Math.round(Rand * Range); //四舍五入
28
25
  }
@@ -34,21 +31,21 @@ var RandomNumUtil = /** @class */ (function () {
34
31
  else {
35
32
  return !isInt ? min : Math.round(min);
36
33
  }
37
- };
34
+ }
38
35
  /**
39
36
  * 打乱数组
40
37
  */
41
- RandomNumUtil.shuffleSort = function (arr) {
42
- var n = arr.length;
43
- var index;
44
- var temp;
38
+ static shuffleSort(arr) {
39
+ let n = arr.length;
40
+ let index;
41
+ let temp;
45
42
  while (n--) {
46
43
  index = Math.floor(Math.random() * n);
47
44
  temp = arr[index];
48
45
  arr[index] = arr[n];
49
46
  arr[n] = temp;
50
47
  }
51
- };
48
+ }
52
49
  /**
53
50
  * 获得偏振系数
54
51
  * @param factor 偏振因子(>0)
@@ -56,29 +53,26 @@ var RandomNumUtil = /** @class */ (function () {
56
53
  * @param positiveIntRadio 正数的比率 (>0的整数)
57
54
  * @return -factor 或者factor
58
55
  */
59
- RandomNumUtil.getPolarizationFactor = function (factor, negativeIntRadio, positiveIntRadio) {
60
- if (factor === void 0) { factor = 1; }
61
- if (negativeIntRadio === void 0) { negativeIntRadio = 1; }
62
- if (positiveIntRadio === void 0) { positiveIntRadio = 1; }
63
- var r = RandomNumUtil.randomNumWithRadio(0, 1, [negativeIntRadio, positiveIntRadio]);
56
+ static getPolarizationFactor(factor = 1, negativeIntRadio = 1, positiveIntRadio = 1) {
57
+ const r = RandomNumUtil.randomNumWithRadio(0, 1, [negativeIntRadio, positiveIntRadio]);
64
58
  if (r == 0)
65
59
  return -1 * factor;
66
60
  return r * factor;
67
- };
61
+ }
68
62
  /**
69
63
  * 按照比率获得随机数(对于整数)
70
64
  * @param min 最小数
71
65
  * @param max 最大数
72
66
  * @param radioArr 比率
73
67
  */
74
- RandomNumUtil.randomNumWithRadio = function (min, max, radioArr) {
75
- var total = 0;
76
- var i;
68
+ static randomNumWithRadio(min, max, radioArr) {
69
+ let total = 0;
70
+ let i;
77
71
  for (i = 0; i < radioArr.length; i++) {
78
72
  total += radioArr[i];
79
73
  }
80
- var r = RandomNumUtil.randomNumBoth(1, total, true);
81
- var target = 0;
74
+ const r = RandomNumUtil.randomNumBoth(1, total, true);
75
+ let target = 0;
82
76
  for (i = 0; i < radioArr.length; i++) {
83
77
  target += radioArr[i];
84
78
  if (r <= target) {
@@ -86,7 +80,6 @@ var RandomNumUtil = /** @class */ (function () {
86
80
  }
87
81
  }
88
82
  return max;
89
- };
90
- return RandomNumUtil;
91
- }());
83
+ }
84
+ }
92
85
  exports.RandomNumUtil = RandomNumUtil;
@@ -5,34 +5,31 @@ exports.SelfDecrypt = void 0;
5
5
  * 解码
6
6
  * @author Aonaufly
7
7
  */
8
- var SelfDecrypt = /** @class */ (function () {
9
- function SelfDecrypt() {
10
- }
11
- SelfDecrypt.b64Decode = function (b64) {
8
+ class SelfDecrypt {
9
+ static b64Decode(b64) {
12
10
  // 浏览器安全解码,自动补 =
13
- var s = b64.replace(/[^A-Za-z0-9+/]/g, '');
14
- var bin = atob(s);
15
- return new Uint8Array(bin.length).map(function (_, i) { return bin.charCodeAt(i); });
16
- };
17
- SelfDecrypt.b64Encode = function (bytes) {
18
- var bin = '';
19
- for (var i = 0; i < bytes.length; i++) {
11
+ const s = b64.replace(/[^A-Za-z0-9+/]/g, '');
12
+ const bin = atob(s);
13
+ return new Uint8Array(bin.length).map((_, i) => bin.charCodeAt(i));
14
+ }
15
+ static b64Encode(bytes) {
16
+ let bin = '';
17
+ for (let i = 0; i < bytes.length; i++) {
20
18
  bin += String.fromCharCode(bytes[i]);
21
19
  }
22
20
  return btoa(bin);
23
- };
24
- SelfDecrypt.xorBytes = function (bytes, key) {
25
- var k = new TextEncoder().encode(key);
26
- return bytes.map(function (b, i) { return b ^ k[i % k.length]; });
27
- };
21
+ }
22
+ static xorBytes(bytes, key) {
23
+ const k = new TextEncoder().encode(key);
24
+ return bytes.map((b, i) => b ^ k[i % k.length]);
25
+ }
28
26
  /**
29
27
  * 解码
30
28
  */
31
- SelfDecrypt.decryptBase64 = function (b64, key) {
32
- var cipher = SelfDecrypt.b64Decode(b64);
33
- var plain = SelfDecrypt.xorBytes(cipher, key);
29
+ static decryptBase64(b64, key) {
30
+ const cipher = SelfDecrypt.b64Decode(b64);
31
+ const plain = SelfDecrypt.xorBytes(cipher, key);
34
32
  return new TextDecoder().decode(plain);
35
- };
36
- return SelfDecrypt;
37
- }());
33
+ }
34
+ }
38
35
  exports.SelfDecrypt = SelfDecrypt;