light-h5-core-lib 2.5.5 → 2.7.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 +35 -37
- package/common/base/BaseSingleton.js +16 -16
- package/common/base/IClear.js +2 -2
- package/common/base/IDestroy.js +2 -2
- package/common/util/BeizerUtil.js +83 -0
- package/common/util/BitUtil.js +43 -43
- package/common/util/CryptUtil.js +38 -0
- package/common/util/DateUtil.js +89 -89
- package/common/util/FloatDigitUtil.js +22 -22
- package/common/util/RandomNumUtil.js +40 -40
- package/common/util/StringUtil.js +81 -81
- package/common/util/UniqueIDUtil.js +21 -21
- package/package.json +18 -15
- package/pool/PoolObj.js +79 -79
- package/type/index.d.ts +44 -0
package/LightCore.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.BaseSingleton = exports.PoolObj = void 0;
|
|
4
|
-
var PoolObj_1 = require("./pool/PoolObj");
|
|
5
|
-
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
6
|
-
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
7
|
-
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
8
|
-
var BitUtil_1 = require("./common/util/BitUtil");
|
|
9
|
-
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
10
|
-
var DateUtil_1 = require("./common/util/DateUtil");
|
|
11
|
-
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
12
|
-
var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
13
|
-
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
14
|
-
var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
15
|
-
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
16
|
-
var StringUtil_1 = require("./common/util/StringUtil");
|
|
17
|
-
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
18
|
-
var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
19
|
-
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
37
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.BaseSingleton = exports.PoolObj = void 0;
|
|
4
|
+
var PoolObj_1 = require("./pool/PoolObj");
|
|
5
|
+
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
6
|
+
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
7
|
+
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
8
|
+
var BitUtil_1 = require("./common/util/BitUtil");
|
|
9
|
+
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
10
|
+
var DateUtil_1 = require("./common/util/DateUtil");
|
|
11
|
+
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
12
|
+
var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
13
|
+
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
14
|
+
var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
15
|
+
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
16
|
+
var StringUtil_1 = require("./common/util/StringUtil");
|
|
17
|
+
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
18
|
+
var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
19
|
+
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
20
|
+
var BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
21
|
+
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
22
|
+
var CryptUtil_1 = require("./common/util/CryptUtil");
|
|
23
|
+
Object.defineProperty(exports, "CryptUtil", { enumerable: true, get: function () { return CryptUtil_1.CryptUtil; } });
|
|
24
|
+
module.exports = {
|
|
25
|
+
PoolObj: PoolObj_1.PoolObj,
|
|
26
|
+
BaseSingleton: BaseSingleton_1.BaseSingleton,
|
|
27
|
+
BitUtil: BitUtil_1.BitUtil,
|
|
28
|
+
DateUtil: DateUtil_1.DateUtil,
|
|
29
|
+
FloatDigitUtil: FloatDigitUtil_1.FloatDigitUtil,
|
|
30
|
+
RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
|
|
31
|
+
StringUtil: StringUtil_1.StringUtil,
|
|
32
|
+
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
33
|
+
BeizerUtil: BeizerUtil_1.BeizerUtil,
|
|
34
|
+
CryptUtil: CryptUtil_1.CryptUtil
|
|
35
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSingleton = void 0;
|
|
4
|
-
var BaseSingleton = /** @class */ (function () {
|
|
5
|
-
function BaseSingleton() {
|
|
6
|
-
}
|
|
7
|
-
BaseSingleton.getInstance = function (c) {
|
|
8
|
-
if (this._instance == null) {
|
|
9
|
-
this._instance = new c();
|
|
10
|
-
}
|
|
11
|
-
return this._instance;
|
|
12
|
-
};
|
|
13
|
-
BaseSingleton._instance = null;
|
|
14
|
-
return BaseSingleton;
|
|
15
|
-
}());
|
|
16
|
-
exports.BaseSingleton = BaseSingleton;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseSingleton = void 0;
|
|
4
|
+
var BaseSingleton = /** @class */ (function () {
|
|
5
|
+
function BaseSingleton() {
|
|
6
|
+
}
|
|
7
|
+
BaseSingleton.getInstance = function (c) {
|
|
8
|
+
if (this._instance == null) {
|
|
9
|
+
this._instance = new c();
|
|
10
|
+
}
|
|
11
|
+
return this._instance;
|
|
12
|
+
};
|
|
13
|
+
BaseSingleton._instance = null;
|
|
14
|
+
return BaseSingleton;
|
|
15
|
+
}());
|
|
16
|
+
exports.BaseSingleton = BaseSingleton;
|
package/common/base/IClear.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/common/base/IDestroy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BeizerUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 贝塞尔曲线运动
|
|
6
|
+
* @author Aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var BeizerUtil = /** @class */ (function () {
|
|
9
|
+
function BeizerUtil() {
|
|
10
|
+
}
|
|
11
|
+
//#region 获得当前坐标
|
|
12
|
+
/**
|
|
13
|
+
* 获得当前坐标
|
|
14
|
+
* @param timer 时间[0,1]
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
BeizerUtil.getPosition = function (points, timer) {
|
|
18
|
+
var x = 0, y = 0;
|
|
19
|
+
var bezier;
|
|
20
|
+
for (var i = 0, n = points.length; i < n; i++) {
|
|
21
|
+
bezier =
|
|
22
|
+
Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
|
|
23
|
+
BeizerUtil.calculationC(i, n);
|
|
24
|
+
x += points[i].x * bezier;
|
|
25
|
+
y += points[i].y * bezier;
|
|
26
|
+
}
|
|
27
|
+
return { x: x, y: y };
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//region 获得路线的长度
|
|
31
|
+
BeizerUtil.distance = function (p1, p2) {
|
|
32
|
+
var dx = p2.x - p1.x;
|
|
33
|
+
var dy = p2.y - p1.y;
|
|
34
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 获得整个路线的长度
|
|
38
|
+
* @param precision 精确度(微积分方案)
|
|
39
|
+
*/
|
|
40
|
+
BeizerUtil.getLength = function (points, precision) {
|
|
41
|
+
if (precision === void 0) { precision = 100; }
|
|
42
|
+
var length = 0;
|
|
43
|
+
var point1;
|
|
44
|
+
var point2;
|
|
45
|
+
for (var t = 0; t < 1; t += 1 / precision) {
|
|
46
|
+
point1 = BeizerUtil.getBezierPoint(points, t);
|
|
47
|
+
point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
|
|
48
|
+
length += BeizerUtil.distance(point1, point2);
|
|
49
|
+
}
|
|
50
|
+
return length;
|
|
51
|
+
};
|
|
52
|
+
BeizerUtil.calculationC = function (i, n) {
|
|
53
|
+
return (BeizerUtil.factorial(n - 1) /
|
|
54
|
+
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
55
|
+
};
|
|
56
|
+
BeizerUtil.factorial = function (num) {
|
|
57
|
+
if (num < 0) {
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
else if (num === 0 || num === 1) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return num * BeizerUtil.factorial(num - 1);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
BeizerUtil.getBezierPoint = function (points, t) {
|
|
68
|
+
if (points.length === 1) {
|
|
69
|
+
return points[0];
|
|
70
|
+
}
|
|
71
|
+
var nextPoints = [];
|
|
72
|
+
var x;
|
|
73
|
+
var y;
|
|
74
|
+
for (var i = 0; i < points.length - 1; i++) {
|
|
75
|
+
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
76
|
+
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
77
|
+
nextPoints.push({ x: x, y: y });
|
|
78
|
+
}
|
|
79
|
+
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
80
|
+
};
|
|
81
|
+
return BeizerUtil;
|
|
82
|
+
}());
|
|
83
|
+
exports.BeizerUtil = BeizerUtil;
|
package/common/util/BitUtil.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 位操作工具(从右向左←)
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var BitUtil = /** @class */ (function () {
|
|
9
|
-
function BitUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 读取uint类型某位的值, bit从1开始
|
|
13
|
-
*/
|
|
14
|
-
BitUtil.getBit = function (value, bit) {
|
|
15
|
-
return (value & (1 << (bit - 1))) >> (bit - 1);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* 设置value 第bit(从1开始)位的值为v(0|1)
|
|
19
|
-
* 谨记bit<32
|
|
20
|
-
*/
|
|
21
|
-
BitUtil.setBit = function (value, bit, v) {
|
|
22
|
-
if (bit > 32) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
if (v == 1) {
|
|
26
|
-
return value | (v << (bit - 1));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return (value &= ~0 ^ (1 << (bit - 1)));
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
/**获取1的个数 */
|
|
33
|
-
BitUtil.get1num = function (value) {
|
|
34
|
-
var count = 0;
|
|
35
|
-
while (value) {
|
|
36
|
-
value = value & (value - 1);
|
|
37
|
-
count++;
|
|
38
|
-
}
|
|
39
|
-
return count;
|
|
40
|
-
};
|
|
41
|
-
return BitUtil;
|
|
42
|
-
}());
|
|
43
|
-
exports.BitUtil = BitUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 位操作工具(从右向左←)
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var BitUtil = /** @class */ (function () {
|
|
9
|
+
function BitUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 读取uint类型某位的值, bit从1开始
|
|
13
|
+
*/
|
|
14
|
+
BitUtil.getBit = function (value, bit) {
|
|
15
|
+
return (value & (1 << (bit - 1))) >> (bit - 1);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 设置value 第bit(从1开始)位的值为v(0|1)
|
|
19
|
+
* 谨记bit<32
|
|
20
|
+
*/
|
|
21
|
+
BitUtil.setBit = function (value, bit, v) {
|
|
22
|
+
if (bit > 32) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
if (v == 1) {
|
|
26
|
+
return value | (v << (bit - 1));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return (value &= ~0 ^ (1 << (bit - 1)));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/**获取1的个数 */
|
|
33
|
+
BitUtil.get1num = function (value) {
|
|
34
|
+
var count = 0;
|
|
35
|
+
while (value) {
|
|
36
|
+
value = value & (value - 1);
|
|
37
|
+
count++;
|
|
38
|
+
}
|
|
39
|
+
return count;
|
|
40
|
+
};
|
|
41
|
+
return BitUtil;
|
|
42
|
+
}());
|
|
43
|
+
exports.BitUtil = BitUtil;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptUtil = void 0;
|
|
4
|
+
var CryptoJS = require("crypto-js");
|
|
5
|
+
/**
|
|
6
|
+
* 加解密工具
|
|
7
|
+
* @author Aonaufly
|
|
8
|
+
*/
|
|
9
|
+
var CryptUtil = /** @class */ (function () {
|
|
10
|
+
function CryptUtil() {
|
|
11
|
+
}
|
|
12
|
+
//#region AES-256 ECB
|
|
13
|
+
/**
|
|
14
|
+
* AES-256 ECB 加密
|
|
15
|
+
*/
|
|
16
|
+
CryptUtil.encryptAes = function (text, key) {
|
|
17
|
+
// 密钥必须是 32 字节(256 位)
|
|
18
|
+
var keyBytes = CryptoJS.enc.Utf8.parse(key);
|
|
19
|
+
var encrypted = CryptoJS.AES.encrypt(text, keyBytes, {
|
|
20
|
+
mode: CryptoJS.mode.ECB,
|
|
21
|
+
padding: CryptoJS.pad.Pkcs7
|
|
22
|
+
});
|
|
23
|
+
return encrypted.toString();
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* AES-256 ECB 解密
|
|
27
|
+
*/
|
|
28
|
+
CryptUtil.decryptAes = function (encryptedText, key) {
|
|
29
|
+
var keyBytes = CryptoJS.enc.Utf8.parse(key);
|
|
30
|
+
var decrypted = CryptoJS.AES.decrypt(encryptedText, keyBytes, {
|
|
31
|
+
mode: CryptoJS.mode.ECB,
|
|
32
|
+
padding: CryptoJS.pad.Pkcs7
|
|
33
|
+
});
|
|
34
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
35
|
+
};
|
|
36
|
+
return CryptUtil;
|
|
37
|
+
}());
|
|
38
|
+
exports.CryptUtil = CryptUtil;
|
package/common/util/DateUtil.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 日期(时间)工具
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var DateUtil = /** @class */ (function () {
|
|
9
|
-
function DateUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 获取指定时间的时间戳 (单位:ms)
|
|
13
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
14
|
-
*/
|
|
15
|
-
DateUtil.getTargetTimeStamp = function (date) {
|
|
16
|
-
return new Date(date).getTime();
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* 获取指定时间的时间秒 (单位:s)
|
|
20
|
-
* @param date 如: "2020-3-14 11:30:30"
|
|
21
|
-
*/
|
|
22
|
-
DateUtil.getTargetSeconds = function (date) {
|
|
23
|
-
return Math.floor(DateUtil.getTargetTimeStamp(date) / 1000);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* 格式化时间(时,分,秒)
|
|
27
|
-
* @param s 秒
|
|
28
|
-
* @param separator 分隔符(default: ":")
|
|
29
|
-
* @param isSingle0 是否补0(default:true)
|
|
30
|
-
* @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
|
|
31
|
-
*/
|
|
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);
|
|
37
|
-
if (isDiscardH && h == 0) {
|
|
38
|
-
return DateUtil.format_MS(s, separator, isSingle0);
|
|
39
|
-
}
|
|
40
|
-
var m = Math.floor((s - h * 3600) / 60);
|
|
41
|
-
s = s - h * 3600 - m * 60;
|
|
42
|
-
var result = isSingle0 ? (h < 10 ? "0".concat(h) : h.toString()) : h.toString();
|
|
43
|
-
result += separator;
|
|
44
|
-
result = result + (isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString());
|
|
45
|
-
result += separator;
|
|
46
|
-
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* 格式化时间(分,秒)
|
|
51
|
-
* @param s 秒
|
|
52
|
-
* @param separator 分隔符(default: ":")
|
|
53
|
-
* @param isSingle0 是否补0(default:true)
|
|
54
|
-
*/
|
|
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);
|
|
59
|
-
s = s - m * 60;
|
|
60
|
-
var result = isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString();
|
|
61
|
-
result += separator;
|
|
62
|
-
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
63
|
-
return result;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计
|
|
67
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
68
|
-
* @return 下一天的时间Second
|
|
69
|
-
* */
|
|
70
|
-
DateUtil.getNextDayTimeStamp = function (nowSecond) {
|
|
71
|
-
return DateUtil.getTodayAppointTimeStamp(nowSecond, 23, 59, 59, 999);
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* 获取今日指定的时间秒, 例如今日20:00
|
|
75
|
-
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
76
|
-
* @param hour 指定的小时数 0~23
|
|
77
|
-
* @param minute 指定的分钟数 0~59
|
|
78
|
-
* @param second 指定的秒数 0~59
|
|
79
|
-
* @param millisecond 指定的毫秒数 0~999
|
|
80
|
-
*/
|
|
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; }
|
|
85
|
-
return Math.ceil(new Date(new Date(nowSecond * 1000).setHours(hour, minute, second, millisecond)).getTime() / 1000);
|
|
86
|
-
};
|
|
87
|
-
return DateUtil;
|
|
88
|
-
}());
|
|
89
|
-
exports.DateUtil = DateUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 日期(时间)工具
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var DateUtil = /** @class */ (function () {
|
|
9
|
+
function DateUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 获取指定时间的时间戳 (单位:ms)
|
|
13
|
+
* @param date 如: "2020-3-14 11:30:30"
|
|
14
|
+
*/
|
|
15
|
+
DateUtil.getTargetTimeStamp = function (date) {
|
|
16
|
+
return new Date(date).getTime();
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 获取指定时间的时间秒 (单位:s)
|
|
20
|
+
* @param date 如: "2020-3-14 11:30:30"
|
|
21
|
+
*/
|
|
22
|
+
DateUtil.getTargetSeconds = function (date) {
|
|
23
|
+
return Math.floor(DateUtil.getTargetTimeStamp(date) / 1000);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* 格式化时间(时,分,秒)
|
|
27
|
+
* @param s 秒
|
|
28
|
+
* @param separator 分隔符(default: ":")
|
|
29
|
+
* @param isSingle0 是否补0(default:true)
|
|
30
|
+
* @param isDiscardH 小时数为0时,是否舍弃显示变成分,秒(default:false)
|
|
31
|
+
*/
|
|
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);
|
|
37
|
+
if (isDiscardH && h == 0) {
|
|
38
|
+
return DateUtil.format_MS(s, separator, isSingle0);
|
|
39
|
+
}
|
|
40
|
+
var m = Math.floor((s - h * 3600) / 60);
|
|
41
|
+
s = s - h * 3600 - m * 60;
|
|
42
|
+
var result = isSingle0 ? (h < 10 ? "0".concat(h) : h.toString()) : h.toString();
|
|
43
|
+
result += separator;
|
|
44
|
+
result = result + (isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString());
|
|
45
|
+
result += separator;
|
|
46
|
+
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 格式化时间(分,秒)
|
|
51
|
+
* @param s 秒
|
|
52
|
+
* @param separator 分隔符(default: ":")
|
|
53
|
+
* @param isSingle0 是否补0(default:true)
|
|
54
|
+
*/
|
|
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);
|
|
59
|
+
s = s - m * 60;
|
|
60
|
+
var result = isSingle0 ? (m < 10 ? "0".concat(m) : m.toString()) : m.toString();
|
|
61
|
+
result += separator;
|
|
62
|
+
result = result + (isSingle0 ? (s < 10 ? "0".concat(s) : s.toString()) : s.toString());
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* 获取下一天的时间(凌晨)秒 存在1ms误差可以忽略不计
|
|
67
|
+
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
68
|
+
* @return 下一天的时间Second
|
|
69
|
+
* */
|
|
70
|
+
DateUtil.getNextDayTimeStamp = function (nowSecond) {
|
|
71
|
+
return DateUtil.getTodayAppointTimeStamp(nowSecond, 23, 59, 59, 999);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 获取今日指定的时间秒, 例如今日20:00
|
|
75
|
+
* @param nowSecond 现在的时间秒 ( 服务器的时间(一般))
|
|
76
|
+
* @param hour 指定的小时数 0~23
|
|
77
|
+
* @param minute 指定的分钟数 0~59
|
|
78
|
+
* @param second 指定的秒数 0~59
|
|
79
|
+
* @param millisecond 指定的毫秒数 0~999
|
|
80
|
+
*/
|
|
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; }
|
|
85
|
+
return Math.ceil(new Date(new Date(nowSecond * 1000).setHours(hour, minute, second, millisecond)).getTime() / 1000);
|
|
86
|
+
};
|
|
87
|
+
return DateUtil;
|
|
88
|
+
}());
|
|
89
|
+
exports.DateUtil = DateUtil;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FloatDigitUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Float精度
|
|
6
|
-
* @author aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var FloatDigitUtil = /** @class */ (function () {
|
|
9
|
-
function FloatDigitUtil() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
|
|
13
|
-
* @param fNum 小数
|
|
14
|
-
* @param digit 精度
|
|
15
|
-
*/
|
|
16
|
-
FloatDigitUtil.formatFloat = function (fNum, digit) {
|
|
17
|
-
var m = Math.pow(10, digit);
|
|
18
|
-
return parseInt((fNum * m).toString(), 10) / m;
|
|
19
|
-
};
|
|
20
|
-
return FloatDigitUtil;
|
|
21
|
-
}());
|
|
22
|
-
exports.FloatDigitUtil = FloatDigitUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FloatDigitUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Float精度
|
|
6
|
+
* @author aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var FloatDigitUtil = /** @class */ (function () {
|
|
9
|
+
function FloatDigitUtil() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
|
|
13
|
+
* @param fNum 小数
|
|
14
|
+
* @param digit 精度
|
|
15
|
+
*/
|
|
16
|
+
FloatDigitUtil.formatFloat = function (fNum, digit) {
|
|
17
|
+
var m = Math.pow(10, digit);
|
|
18
|
+
return parseInt((fNum * m).toString(), 10) / m;
|
|
19
|
+
};
|
|
20
|
+
return FloatDigitUtil;
|
|
21
|
+
}());
|
|
22
|
+
exports.FloatDigitUtil = FloatDigitUtil;
|
|
@@ -1,40 +1,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
|
-
return RandomNumUtil;
|
|
39
|
-
}());
|
|
40
|
-
exports.RandomNumUtil = RandomNumUtil;
|
|
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
|
+
return RandomNumUtil;
|
|
39
|
+
}());
|
|
40
|
+
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,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "light-h5-core-lib",
|
|
3
|
+
"version": "2.7.0",
|
|
4
|
+
"description": "h5 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
|
+
"h5",
|
|
12
|
+
"core",
|
|
13
|
+
"lib"
|
|
14
|
+
],
|
|
15
|
+
"author": "Aonaufly",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"crypto-js": "^4.2.0"
|
|
19
|
+
}
|
|
17
20
|
}
|
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 cup 容量
|
|
11
|
-
*/
|
|
12
|
-
function PoolObj(cup) {
|
|
13
|
-
if (cup === void 0) { cup = 5; }
|
|
14
|
-
this._cup = cup;
|
|
15
|
-
this._pool = [];
|
|
16
|
-
}
|
|
17
|
-
PoolObj.prototype.put = function (obj) {
|
|
18
|
-
if (!obj || this._pool.length >= this._cup)
|
|
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, "cup", {
|
|
29
|
-
/**
|
|
30
|
-
* 获取容量(容积)
|
|
31
|
-
*/
|
|
32
|
-
get: function () {
|
|
33
|
-
return this._cup;
|
|
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 cup 容量
|
|
11
|
+
*/
|
|
12
|
+
function PoolObj(cup) {
|
|
13
|
+
if (cup === void 0) { cup = 5; }
|
|
14
|
+
this._cup = cup;
|
|
15
|
+
this._pool = [];
|
|
16
|
+
}
|
|
17
|
+
PoolObj.prototype.put = function (obj) {
|
|
18
|
+
if (!obj || this._pool.length >= this._cup)
|
|
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, "cup", {
|
|
29
|
+
/**
|
|
30
|
+
* 获取容量(容积)
|
|
31
|
+
*/
|
|
32
|
+
get: function () {
|
|
33
|
+
return this._cup;
|
|
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
|
@@ -159,5 +159,49 @@ export declare class UniqueIDUtil {
|
|
|
159
159
|
/**生成复合的Key值*/
|
|
160
160
|
static getCompositeKey(key: string | number, uniqueId: string): string;
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* 贝塞尔曲线运动
|
|
164
|
+
* @author Aonaufly
|
|
165
|
+
*/
|
|
166
|
+
export declare class BeizerUtil {
|
|
167
|
+
/**
|
|
168
|
+
* 获得当前坐标
|
|
169
|
+
* @param timer 时间[0,1]
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
static getPosition(points: {
|
|
173
|
+
x: number;
|
|
174
|
+
y: number;
|
|
175
|
+
}[], timer: number): {
|
|
176
|
+
x: number;
|
|
177
|
+
y: number;
|
|
178
|
+
};
|
|
179
|
+
private static calculationC;
|
|
180
|
+
private static factorial;
|
|
181
|
+
private static distance;
|
|
182
|
+
/**
|
|
183
|
+
* 获得整个路线的长度
|
|
184
|
+
* @param precision 精确度(微积分方案)
|
|
185
|
+
*/
|
|
186
|
+
static getLength(points: {
|
|
187
|
+
x: number;
|
|
188
|
+
y: number;
|
|
189
|
+
}[], precision?: number): number;
|
|
190
|
+
private static getBezierPoint;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 加解密工具
|
|
194
|
+
* @author Aonaufly
|
|
195
|
+
*/
|
|
196
|
+
export declare class CryptUtil {
|
|
197
|
+
/**
|
|
198
|
+
* AES-256 ECB 加密
|
|
199
|
+
*/
|
|
200
|
+
static encryptAes(text: string, key: string): string;
|
|
201
|
+
/**
|
|
202
|
+
* AES-256 ECB 解密
|
|
203
|
+
*/
|
|
204
|
+
static decryptAes(encryptedText: string, key: string): string;
|
|
205
|
+
}
|
|
162
206
|
|
|
163
207
|
export {};
|