light-h5-core-lib 2.7.4 → 2.8.0
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/LightCore.js +44 -38
- package/common/base/BaseSingleton.js +23 -23
- package/common/base/IClear.js +2 -2
- package/common/base/IDestroy.js +2 -2
- package/common/md5/MD5.js +346 -346
- package/common/util/BeizerUtil.js +83 -83
- package/common/util/BitUtil.js +43 -43
- package/common/util/Crc32Util.js +35 -0
- package/common/util/CryptUtil.js +4 -2
- package/common/util/DateUtil.js +89 -89
- package/common/util/FloatDigitUtil.js +22 -22
- package/common/util/PromiseUtil.js +74 -0
- package/common/util/RandomNumUtil.js +54 -40
- package/common/util/StringUtil.js +81 -81
- package/common/util/UniqueIDUtil.js +21 -21
- package/package.json +16 -18
- package/pool/PoolObj.js +79 -79
- package/type/index.d.ts +30 -15
|
@@ -1,40 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RandomNumUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 随机数生成工具
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var RandomNumUtil = /** @class */ (function () {
|
|
9
|
-
function RandomNumUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* <b>( min ≤ r ≤ max )</b>
|
|
15
|
-
*
|
|
16
|
-
* @param min 最小数
|
|
17
|
-
* @param max 最大数
|
|
18
|
-
* @param isInt 是否返回整数
|
|
19
|
-
*/
|
|
20
|
-
RandomNumUtil.randomNumBoth = function (min, max, isInt) {
|
|
21
|
-
if (isInt === void 0) { isInt = true; }
|
|
22
|
-
var Range = max - min;
|
|
23
|
-
if (Range > 0.0) {
|
|
24
|
-
var Rand = Math.random();
|
|
25
|
-
var num = void 0;
|
|
26
|
-
if (isInt) {
|
|
27
|
-
num = min + Math.round(Rand * Range); //四舍五入
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
num = min + Rand * Range;
|
|
31
|
-
}
|
|
32
|
-
return num;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return isInt ? min : Math.round(min);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RandomNumUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 随机数生成工具
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var RandomNumUtil = /** @class */ (function () {
|
|
9
|
+
function RandomNumUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 获取一定范围的随机整数
|
|
13
|
+
*
|
|
14
|
+
* <b>( min ≤ r ≤ max )</b>
|
|
15
|
+
*
|
|
16
|
+
* @param min 最小数
|
|
17
|
+
* @param max 最大数
|
|
18
|
+
* @param isInt 是否返回整数
|
|
19
|
+
*/
|
|
20
|
+
RandomNumUtil.randomNumBoth = function (min, max, isInt) {
|
|
21
|
+
if (isInt === void 0) { isInt = true; }
|
|
22
|
+
var Range = max - min;
|
|
23
|
+
if (Range > 0.0) {
|
|
24
|
+
var Rand = Math.random();
|
|
25
|
+
var num = void 0;
|
|
26
|
+
if (isInt) {
|
|
27
|
+
num = min + Math.round(Rand * Range); //四舍五入
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
num = min + Rand * Range;
|
|
31
|
+
}
|
|
32
|
+
return num;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return isInt ? min : Math.round(min);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 打乱数组
|
|
40
|
+
*/
|
|
41
|
+
RandomNumUtil.shuffleSort = function (arr) {
|
|
42
|
+
var n = arr.length;
|
|
43
|
+
var index;
|
|
44
|
+
var temp;
|
|
45
|
+
while (n--) {
|
|
46
|
+
index = Math.floor(Math.random() * n);
|
|
47
|
+
temp = arr[index];
|
|
48
|
+
arr[index] = arr[n];
|
|
49
|
+
arr[n] = temp;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return RandomNumUtil;
|
|
53
|
+
}());
|
|
54
|
+
exports.RandomNumUtil = RandomNumUtil;
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 字符串工具
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var StringUtil = /** @class */ (function () {
|
|
9
|
-
function StringUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 字符串的格式化 , 使用 {index = 0}的模式
|
|
13
|
-
* @param str 源字符串
|
|
14
|
-
* @param args 填充参数
|
|
15
|
-
*/
|
|
16
|
-
StringUtil.format = function (str) {
|
|
17
|
-
var args = [];
|
|
18
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
19
|
-
args[_i - 1] = arguments[_i];
|
|
20
|
-
}
|
|
21
|
-
if (!args || args.length == 0)
|
|
22
|
-
return str;
|
|
23
|
-
for (var i = 0, j = args.length; i < j; i++) {
|
|
24
|
-
str = str.replace("{".concat(i, "}"), args[i]);
|
|
25
|
-
}
|
|
26
|
-
return str;
|
|
27
|
-
};
|
|
28
|
-
StringUtil.code2utf8 = function (uni) {
|
|
29
|
-
var uni2 = uni.toString(2);
|
|
30
|
-
if (uni < 128) {
|
|
31
|
-
return uni.toString(16);
|
|
32
|
-
}
|
|
33
|
-
else if (uni < 2048) {
|
|
34
|
-
uni2 = ("00000000000000000" + uni2).slice(-11);
|
|
35
|
-
var s1 = parseInt("110" + uni2.substring(0, 5), 2);
|
|
36
|
-
var s2 = parseInt("10" + uni2.substring(5), 2);
|
|
37
|
-
return s1.toString(16) + "," + s2.toString(16);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
uni2 = ("00000000000000000" + uni2).slice(-16);
|
|
41
|
-
var s1 = parseInt("1110" + uni2.substring(0, 4), 2);
|
|
42
|
-
var s2 = parseInt("10" + uni2.substring(4, 10), 2);
|
|
43
|
-
var s3 = parseInt("10" + uni2.substring(10), 2);
|
|
44
|
-
return s1.toString(16) + "," + s2.toString(16) + "," + s3.toString(16);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* 将字符串转化成UTF8的Buffer
|
|
49
|
-
* @param str 字符串
|
|
50
|
-
*/
|
|
51
|
-
StringUtil.string2UTF8Buffer = function (str) {
|
|
52
|
-
var val = "";
|
|
53
|
-
for (var i = 0; i < str.length; i++) {
|
|
54
|
-
val += "," + StringUtil.code2utf8(str.charCodeAt(i));
|
|
55
|
-
}
|
|
56
|
-
val += ",00";
|
|
57
|
-
// 将16进制转化为ArrayBuffer
|
|
58
|
-
return new Uint8Array(val.match(/[\da-f]{2}/gi).map(function (h) {
|
|
59
|
-
return parseInt(h, 16);
|
|
60
|
-
})).buffer;
|
|
61
|
-
};
|
|
62
|
-
// /**
|
|
63
|
-
// * 将buffer转化成UTF8
|
|
64
|
-
// * @param buffer
|
|
65
|
-
// */
|
|
66
|
-
// public static buffer2UTF8String(buffer: ArrayBuffer): string {
|
|
67
|
-
// const encodedString: string = String.fromCharCode.apply(null, new Uint8Array(buffer));
|
|
68
|
-
// // const decodedString: string = decodeURIComponent(escape(atob(encodedString)));
|
|
69
|
-
// return encodedString;
|
|
70
|
-
// }
|
|
71
|
-
/* 将buffer转化成UTF8
|
|
72
|
-
* @param buffer
|
|
73
|
-
*/
|
|
74
|
-
StringUtil.buffer2UTF8String = function (buffer) {
|
|
75
|
-
var uint8Array = new Uint8Array(buffer);
|
|
76
|
-
var data = uint8Array.reduce(function (acc, i) { return (acc += String.fromCharCode.apply(null, [i])); }, "");
|
|
77
|
-
return data;
|
|
78
|
-
};
|
|
79
|
-
return StringUtil;
|
|
80
|
-
}());
|
|
81
|
-
exports.StringUtil = StringUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 字符串工具
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var StringUtil = /** @class */ (function () {
|
|
9
|
+
function StringUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 字符串的格式化 , 使用 {index = 0}的模式
|
|
13
|
+
* @param str 源字符串
|
|
14
|
+
* @param args 填充参数
|
|
15
|
+
*/
|
|
16
|
+
StringUtil.format = function (str) {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i - 1] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
if (!args || args.length == 0)
|
|
22
|
+
return str;
|
|
23
|
+
for (var i = 0, j = args.length; i < j; i++) {
|
|
24
|
+
str = str.replace("{".concat(i, "}"), args[i]);
|
|
25
|
+
}
|
|
26
|
+
return str;
|
|
27
|
+
};
|
|
28
|
+
StringUtil.code2utf8 = function (uni) {
|
|
29
|
+
var uni2 = uni.toString(2);
|
|
30
|
+
if (uni < 128) {
|
|
31
|
+
return uni.toString(16);
|
|
32
|
+
}
|
|
33
|
+
else if (uni < 2048) {
|
|
34
|
+
uni2 = ("00000000000000000" + uni2).slice(-11);
|
|
35
|
+
var s1 = parseInt("110" + uni2.substring(0, 5), 2);
|
|
36
|
+
var s2 = parseInt("10" + uni2.substring(5), 2);
|
|
37
|
+
return s1.toString(16) + "," + s2.toString(16);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
uni2 = ("00000000000000000" + uni2).slice(-16);
|
|
41
|
+
var s1 = parseInt("1110" + uni2.substring(0, 4), 2);
|
|
42
|
+
var s2 = parseInt("10" + uni2.substring(4, 10), 2);
|
|
43
|
+
var s3 = parseInt("10" + uni2.substring(10), 2);
|
|
44
|
+
return s1.toString(16) + "," + s2.toString(16) + "," + s3.toString(16);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 将字符串转化成UTF8的Buffer
|
|
49
|
+
* @param str 字符串
|
|
50
|
+
*/
|
|
51
|
+
StringUtil.string2UTF8Buffer = function (str) {
|
|
52
|
+
var val = "";
|
|
53
|
+
for (var i = 0; i < str.length; i++) {
|
|
54
|
+
val += "," + StringUtil.code2utf8(str.charCodeAt(i));
|
|
55
|
+
}
|
|
56
|
+
val += ",00";
|
|
57
|
+
// 将16进制转化为ArrayBuffer
|
|
58
|
+
return new Uint8Array(val.match(/[\da-f]{2}/gi).map(function (h) {
|
|
59
|
+
return parseInt(h, 16);
|
|
60
|
+
})).buffer;
|
|
61
|
+
};
|
|
62
|
+
// /**
|
|
63
|
+
// * 将buffer转化成UTF8
|
|
64
|
+
// * @param buffer
|
|
65
|
+
// */
|
|
66
|
+
// public static buffer2UTF8String(buffer: ArrayBuffer): string {
|
|
67
|
+
// const encodedString: string = String.fromCharCode.apply(null, new Uint8Array(buffer));
|
|
68
|
+
// // const decodedString: string = decodeURIComponent(escape(atob(encodedString)));
|
|
69
|
+
// return encodedString;
|
|
70
|
+
// }
|
|
71
|
+
/* 将buffer转化成UTF8
|
|
72
|
+
* @param buffer
|
|
73
|
+
*/
|
|
74
|
+
StringUtil.buffer2UTF8String = function (buffer) {
|
|
75
|
+
var uint8Array = new Uint8Array(buffer);
|
|
76
|
+
var data = uint8Array.reduce(function (acc, i) { return (acc += String.fromCharCode.apply(null, [i])); }, "");
|
|
77
|
+
return data;
|
|
78
|
+
};
|
|
79
|
+
return StringUtil;
|
|
80
|
+
}());
|
|
81
|
+
exports.StringUtil = StringUtil;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniqueIDUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 唯一ID生成器
|
|
6
|
-
* @author Aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var UniqueIDUtil = /** @class */ (function () {
|
|
9
|
-
function UniqueIDUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**生成唯一ID值*/
|
|
12
|
-
UniqueIDUtil.getUniqueId = function () {
|
|
13
|
-
return new Date().getTime() + Math.random().toString(36).substring(2);
|
|
14
|
-
};
|
|
15
|
-
/**生成复合的Key值*/
|
|
16
|
-
UniqueIDUtil.getCompositeKey = function (key, uniqueId) {
|
|
17
|
-
return "".concat(key, "-id:").concat(uniqueId);
|
|
18
|
-
};
|
|
19
|
-
return UniqueIDUtil;
|
|
20
|
-
}());
|
|
21
|
-
exports.UniqueIDUtil = UniqueIDUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueIDUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 唯一ID生成器
|
|
6
|
+
* @author Aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var UniqueIDUtil = /** @class */ (function () {
|
|
9
|
+
function UniqueIDUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**生成唯一ID值*/
|
|
12
|
+
UniqueIDUtil.getUniqueId = function () {
|
|
13
|
+
return new Date().getTime() + Math.random().toString(36).substring(2);
|
|
14
|
+
};
|
|
15
|
+
/**生成复合的Key值*/
|
|
16
|
+
UniqueIDUtil.getCompositeKey = function (key, uniqueId) {
|
|
17
|
+
return "".concat(key, "-id:").concat(uniqueId);
|
|
18
|
+
};
|
|
19
|
+
return UniqueIDUtil;
|
|
20
|
+
}());
|
|
21
|
+
exports.UniqueIDUtil = UniqueIDUtil;
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"crypto-es": "^2.1.0"
|
|
19
|
-
}
|
|
2
|
+
"name": "light-h5-core-lib",
|
|
3
|
+
"version": "2.8.0",
|
|
4
|
+
"description": "light core lib",
|
|
5
|
+
"main": "./LightCore.js",
|
|
6
|
+
"types": "./type/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"core",
|
|
12
|
+
"h5",
|
|
13
|
+
"lib"
|
|
14
|
+
],
|
|
15
|
+
"author": "Aonaufly",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"dependencies": {}
|
|
20
18
|
}
|
package/pool/PoolObj.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PoolObj = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 对象池(泛型)
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var PoolObj = /** @class */ (function () {
|
|
9
|
-
/**
|
|
10
|
-
* @param cap 容量(容积)
|
|
11
|
-
*/
|
|
12
|
-
function PoolObj(cap) {
|
|
13
|
-
if (cap === void 0) { cap = 5; }
|
|
14
|
-
this._cap = cap;
|
|
15
|
-
this._pool = [];
|
|
16
|
-
}
|
|
17
|
-
PoolObj.prototype.put = function (obj) {
|
|
18
|
-
if (!obj || this._pool.length >= this._cap)
|
|
19
|
-
return false;
|
|
20
|
-
this._pool.push(obj);
|
|
21
|
-
return true;
|
|
22
|
-
};
|
|
23
|
-
PoolObj.prototype.one = function () {
|
|
24
|
-
if (this._pool.length == 0)
|
|
25
|
-
return null;
|
|
26
|
-
return this._pool.shift();
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(PoolObj.prototype, "cap", {
|
|
29
|
-
/**
|
|
30
|
-
* 获取容量(容积)
|
|
31
|
-
*/
|
|
32
|
-
get: function () {
|
|
33
|
-
return this._cap;
|
|
34
|
-
},
|
|
35
|
-
enumerable: false,
|
|
36
|
-
configurable: true
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(PoolObj.prototype, "size", {
|
|
39
|
-
/**
|
|
40
|
-
* 获取当前数量(已经保存的元素个数)
|
|
41
|
-
*/
|
|
42
|
-
get: function () {
|
|
43
|
-
if (!this._pool)
|
|
44
|
-
return 0;
|
|
45
|
-
return this._pool.length;
|
|
46
|
-
},
|
|
47
|
-
enumerable: false,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* 清理对象池
|
|
52
|
-
*/
|
|
53
|
-
PoolObj.prototype.clear = function () {
|
|
54
|
-
if (!this._pool)
|
|
55
|
-
return;
|
|
56
|
-
if (this._pool.length == 0)
|
|
57
|
-
return;
|
|
58
|
-
var obj;
|
|
59
|
-
for (var i = 0, j = this._pool.length; i < j; i++) {
|
|
60
|
-
obj = this._pool[i];
|
|
61
|
-
if (obj.destroy) {
|
|
62
|
-
obj.destroy();
|
|
63
|
-
}
|
|
64
|
-
else if (obj.onDestroy) {
|
|
65
|
-
obj.onDestroy();
|
|
66
|
-
}
|
|
67
|
-
obj = null;
|
|
68
|
-
}
|
|
69
|
-
this._pool.length = 0;
|
|
70
|
-
};
|
|
71
|
-
PoolObj.prototype.destroy = function (isCleared) {
|
|
72
|
-
if (!isCleared) {
|
|
73
|
-
this.clear();
|
|
74
|
-
}
|
|
75
|
-
this._pool && (this._pool = null);
|
|
76
|
-
};
|
|
77
|
-
return PoolObj;
|
|
78
|
-
}());
|
|
79
|
-
exports.PoolObj = PoolObj;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PoolObj = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 对象池(泛型)
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var PoolObj = /** @class */ (function () {
|
|
9
|
+
/**
|
|
10
|
+
* @param cap 容量(容积)
|
|
11
|
+
*/
|
|
12
|
+
function PoolObj(cap) {
|
|
13
|
+
if (cap === void 0) { cap = 5; }
|
|
14
|
+
this._cap = cap;
|
|
15
|
+
this._pool = [];
|
|
16
|
+
}
|
|
17
|
+
PoolObj.prototype.put = function (obj) {
|
|
18
|
+
if (!obj || this._pool.length >= this._cap)
|
|
19
|
+
return false;
|
|
20
|
+
this._pool.push(obj);
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
PoolObj.prototype.one = function () {
|
|
24
|
+
if (this._pool.length == 0)
|
|
25
|
+
return null;
|
|
26
|
+
return this._pool.shift();
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(PoolObj.prototype, "cap", {
|
|
29
|
+
/**
|
|
30
|
+
* 获取容量(容积)
|
|
31
|
+
*/
|
|
32
|
+
get: function () {
|
|
33
|
+
return this._cap;
|
|
34
|
+
},
|
|
35
|
+
enumerable: false,
|
|
36
|
+
configurable: true
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(PoolObj.prototype, "size", {
|
|
39
|
+
/**
|
|
40
|
+
* 获取当前数量(已经保存的元素个数)
|
|
41
|
+
*/
|
|
42
|
+
get: function () {
|
|
43
|
+
if (!this._pool)
|
|
44
|
+
return 0;
|
|
45
|
+
return this._pool.length;
|
|
46
|
+
},
|
|
47
|
+
enumerable: false,
|
|
48
|
+
configurable: true
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* 清理对象池
|
|
52
|
+
*/
|
|
53
|
+
PoolObj.prototype.clear = function () {
|
|
54
|
+
if (!this._pool)
|
|
55
|
+
return;
|
|
56
|
+
if (this._pool.length == 0)
|
|
57
|
+
return;
|
|
58
|
+
var obj;
|
|
59
|
+
for (var i = 0, j = this._pool.length; i < j; i++) {
|
|
60
|
+
obj = this._pool[i];
|
|
61
|
+
if (obj.destroy) {
|
|
62
|
+
obj.destroy();
|
|
63
|
+
}
|
|
64
|
+
else if (obj.onDestroy) {
|
|
65
|
+
obj.onDestroy();
|
|
66
|
+
}
|
|
67
|
+
obj = null;
|
|
68
|
+
}
|
|
69
|
+
this._pool.length = 0;
|
|
70
|
+
};
|
|
71
|
+
PoolObj.prototype.destroy = function (isCleared) {
|
|
72
|
+
if (!isCleared) {
|
|
73
|
+
this.clear();
|
|
74
|
+
}
|
|
75
|
+
this._pool && (this._pool = null);
|
|
76
|
+
};
|
|
77
|
+
return PoolObj;
|
|
78
|
+
}());
|
|
79
|
+
exports.PoolObj = PoolObj;
|
package/type/index.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export declare class FloatDigitUtil {
|
|
|
125
125
|
*/
|
|
126
126
|
export declare class RandomNumUtil {
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* 获取一定范围的随机整数
|
|
129
129
|
*
|
|
130
130
|
* <b>( min ≤ r ≤ max )</b>
|
|
131
131
|
*
|
|
@@ -134,6 +134,10 @@ export declare class RandomNumUtil {
|
|
|
134
134
|
* @param isInt 是否返回整数
|
|
135
135
|
*/
|
|
136
136
|
static randomNumBoth(min: number, max: number, isInt?: boolean): number;
|
|
137
|
+
/**
|
|
138
|
+
* 打乱数组
|
|
139
|
+
*/
|
|
140
|
+
static shuffleSort<T>(arr: T[]): void;
|
|
137
141
|
}
|
|
138
142
|
/**
|
|
139
143
|
* 字符串工具
|
|
@@ -194,20 +198,6 @@ export declare class BeizerUtil {
|
|
|
194
198
|
}[], precision?: number): number;
|
|
195
199
|
private static getBezierPoint;
|
|
196
200
|
}
|
|
197
|
-
/**
|
|
198
|
-
* 加解密工具
|
|
199
|
-
* @author Aonaufly
|
|
200
|
-
*/
|
|
201
|
-
export declare class CryptUtil {
|
|
202
|
-
/** 加密函数AES-256 ECB */
|
|
203
|
-
static encryptAes(plainText: string, key: string): string;
|
|
204
|
-
/**解密函数AES-256 ECB*/
|
|
205
|
-
static decryptAes(cipherText: string, key: string): string;
|
|
206
|
-
/**
|
|
207
|
-
* MD5
|
|
208
|
-
*/
|
|
209
|
-
static md5(text: string): string;
|
|
210
|
-
}
|
|
211
201
|
export declare class MD5 extends BaseSingleton<MD5> {
|
|
212
202
|
private hexcase;
|
|
213
203
|
private b64pad;
|
|
@@ -238,5 +228,30 @@ export declare class MD5 extends BaseSingleton<MD5> {
|
|
|
238
228
|
safe_add(x: any, y: any): number;
|
|
239
229
|
bit_rol(num: any, cnt: any): number;
|
|
240
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* 异步处理工具
|
|
233
|
+
* @author Aonaufly
|
|
234
|
+
*/
|
|
235
|
+
export declare class PromiseUtil {
|
|
236
|
+
/**
|
|
237
|
+
* 执行所有异步并返回数据
|
|
238
|
+
*/
|
|
239
|
+
static all(promiseArr: Promise<any>[]): Promise<any>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Crc32验证工具
|
|
243
|
+
* @author Aonaufly
|
|
244
|
+
*/
|
|
245
|
+
export declare class Crc32Util {
|
|
246
|
+
private static table;
|
|
247
|
+
/**
|
|
248
|
+
* Crc32 number
|
|
249
|
+
*/
|
|
250
|
+
static getCrc32Number(str: string, crc?: number): number;
|
|
251
|
+
/**
|
|
252
|
+
* Crc32 string
|
|
253
|
+
*/
|
|
254
|
+
static getCrc32String(str: string, crc?: number): string;
|
|
255
|
+
}
|
|
241
256
|
|
|
242
257
|
export {};
|