light-h5-core-lib 2.7.1 → 2.7.2

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.
@@ -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,20 @@
1
1
  {
2
- "name": "light-h5-core-lib",
3
- "version": "2.7.1",
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
- }
2
+ "name": "light-h5-core-lib",
3
+ "version": "2.7.2",
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": {
18
+ "crypto-ts": "^1.0.2"
19
+ }
20
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 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
@@ -12,17 +12,17 @@ export interface IClear extends IDestroy {
12
12
  */
13
13
  export declare class PoolObj<T> implements IClear {
14
14
  private _pool;
15
- private _cup;
15
+ private _cap;
16
16
  /**
17
- * @param cup 容量
17
+ * @param cap 容量(容积)
18
18
  */
19
- constructor(cup?: number);
19
+ constructor(cap?: number);
20
20
  put(obj: T): boolean;
21
21
  one(): T;
22
22
  /**
23
23
  * 获取容量(容积)
24
24
  */
25
- get cup(): number;
25
+ get cap(): number;
26
26
  /**
27
27
  * 获取当前数量(已经保存的元素个数)
28
28
  */
@@ -33,11 +33,16 @@ export declare class PoolObj<T> implements IClear {
33
33
  clear(): void;
34
34
  destroy(isCleared?: boolean): void;
35
35
  }
36
- export declare class BaseSingleton<T> {
36
+ /**
37
+ * 泛型单例基类
38
+ * @author Aonaufly
39
+ */
40
+ export declare abstract class BaseSingleton<T> implements IDestroy {
37
41
  private static _instance;
38
42
  static getInstance<T>(c: {
39
43
  new (): T;
40
44
  }): T;
45
+ destroy(): void;
41
46
  }
42
47
  /**
43
48
  * 位操作工具(从右向左←)
@@ -194,18 +199,41 @@ export declare class BeizerUtil {
194
199
  * @author Aonaufly
195
200
  */
196
201
  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
- /**
206
- MD5
207
- */
208
- static md5(message: string): string;
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
+ static md5(input: string): string;
207
+ }
208
+ export declare class MD5 extends BaseSingleton<MD5> {
209
+ private hexcase;
210
+ private b64pad;
211
+ constructor();
212
+ hex_md5(s: string): string;
213
+ b64_md5(s: string): string;
214
+ any_md5(s: string, e: string): string;
215
+ hex_hmac_md5(k: string, d: string): string;
216
+ private b64_hmac_md5;
217
+ private any_hmac_md5;
218
+ md5_vm_test(): boolean;
219
+ rstr_md5(s: string): string;
220
+ rstr_hmac_md5(key: string, data: string): string;
221
+ rstr2hex(input: string): string;
222
+ rstr2b64(input: string): string;
223
+ rstr2any(input: string, encoding: string): string;
224
+ str2rstr_utf8(input: string): string;
225
+ str2rstr_utf16le(input: string): string;
226
+ str2rstr_utf16be(input: string): string;
227
+ rstr2binl(input: string): any[];
228
+ binl2rstr(input: number[]): string;
229
+ binl_md5(x: number[], len: number): number[];
230
+ md5_cmn(q: any, a: any, b: any, x: any, s: any, t: any): number;
231
+ md5_ff(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
232
+ md5_gg(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
233
+ md5_hh(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
234
+ md5_ii(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
235
+ safe_add(x: any, y: any): number;
236
+ bit_rol(num: any, cnt: any): number;
209
237
  }
210
238
 
211
239
  export {};