light-h5-core-lib 2.5.2 → 2.5.4

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 CHANGED
@@ -1,24 +1,37 @@
1
- import { PoolObj as corePoolObj } from "./pool/PoolObj";
2
- import { BaseSingleton as coreBaseSingleton } from "./common/base/BaseSingleton";
3
- import { BitUtil as coreBitUtil } from "./common/util/BitUtil";
4
- import { DateUtil as coreDateUtil } from "./common/util/DateUtil";
5
- import { FloatDigitUtil as coreFloatDigitUtil } from "./common/util/FloatDigitUtil";
6
- import { RandomNumUtil as coreRandomNumUtil } from "./common/util/RandomNumUtil";
7
- import { StringUtil as coreStringUtil } from "./common/util/StringUtil";
8
- import { UniqueIDUtil as coreUniqueIDUtil } from "./common/util/UniqueIDUtil";
9
- module.exports.PoolObj = corePoolObj;
10
- module.exports.BaseSingleton = coreBaseSingleton;
11
- module.exports.BitUtil = coreBitUtil;
12
- module.exports.DateUtil = coreDateUtil;
13
- module.exports.FloatDigitUtil = coreFloatDigitUtil;
14
- module.exports.RandomNumUtil = coreRandomNumUtil;
15
- module.exports.StringUtil = coreStringUtil;
16
- module.exports.UniqueIDUtil = coreUniqueIDUtil;
17
- // export { a };
18
- // export { BaseSingleton };
19
- // export { BitUtil };
20
- // export { DateUtil };
21
- // export { FloatDigitUtil };
22
- // export { RandomNumUtil };
23
- // export { StringUtil };
24
- // export { UniqueIDUtil };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coreUniqueIDUtil = exports.coreStringUtil = exports.coreRandomNumUtil = exports.coreFloatDigitUtil = exports.coreDateUtil = exports.coreBitUtil = exports.coreBaseSingleton = exports.corePoolObj = void 0;
4
+ var PoolObj_1 = require("./pool/PoolObj");
5
+ Object.defineProperty(exports, "corePoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
6
+ var BaseSingleton_1 = require("./common/base/BaseSingleton");
7
+ Object.defineProperty(exports, "coreBaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
8
+ var BitUtil_1 = require("./common/util/BitUtil");
9
+ Object.defineProperty(exports, "coreBitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
10
+ var DateUtil_1 = require("./common/util/DateUtil");
11
+ Object.defineProperty(exports, "coreDateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
12
+ var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
13
+ Object.defineProperty(exports, "coreFloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
14
+ var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
15
+ Object.defineProperty(exports, "coreRandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
16
+ var StringUtil_1 = require("./common/util/StringUtil");
17
+ Object.defineProperty(exports, "coreStringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
18
+ var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
19
+ Object.defineProperty(exports, "coreUniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
20
+ module.exports.PoolObj = PoolObj_1.PoolObj;
21
+ module.exports.BaseSingleton = BaseSingleton_1.BaseSingleton;
22
+ module.exports.BitUtil = BitUtil_1.BitUtil;
23
+ module.exports.DateUtil = DateUtil_1.DateUtil;
24
+ module.exports.FloatDigitUtil = FloatDigitUtil_1.FloatDigitUtil;
25
+ module.exports.RandomNumUtil = RandomNumUtil_1.RandomNumUtil;
26
+ module.exports.StringUtil = StringUtil_1.StringUtil;
27
+ module.exports.UniqueIDUtil = UniqueIDUtil_1.UniqueIDUtil;
28
+ module.exports = {
29
+ PoolObj: PoolObj_1.PoolObj,
30
+ BaseSingleton: BaseSingleton_1.BaseSingleton,
31
+ BitUtil: BitUtil_1.BitUtil,
32
+ DateUtil: DateUtil_1.DateUtil,
33
+ FloatDigitUtil: FloatDigitUtil_1.FloatDigitUtil,
34
+ RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
35
+ StringUtil: StringUtil_1.StringUtil,
36
+ UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
37
+ };
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSingleton = void 0;
1
4
  var BaseSingleton = /** @class */ (function () {
2
5
  function BaseSingleton() {
3
6
  }
@@ -10,4 +13,4 @@ var BaseSingleton = /** @class */ (function () {
10
13
  BaseSingleton._instance = null;
11
14
  return BaseSingleton;
12
15
  }());
13
- export { BaseSingleton };
16
+ exports.BaseSingleton = BaseSingleton;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitUtil = void 0;
1
4
  /**
2
5
  * 位操作工具(从右向左←)
3
6
  * @author aonaufly
@@ -37,4 +40,4 @@ var BitUtil = /** @class */ (function () {
37
40
  };
38
41
  return BitUtil;
39
42
  }());
40
- export { BitUtil };
43
+ exports.BitUtil = BitUtil;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateUtil = void 0;
1
4
  /**
2
5
  * 日期(时间)工具
3
6
  * @author aonaufly
@@ -83,4 +86,4 @@ var DateUtil = /** @class */ (function () {
83
86
  };
84
87
  return DateUtil;
85
88
  }());
86
- export { DateUtil };
89
+ exports.DateUtil = DateUtil;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FloatDigitUtil = void 0;
1
4
  /**
2
5
  * Float精度
3
6
  * @author aonaufly
@@ -16,4 +19,4 @@ var FloatDigitUtil = /** @class */ (function () {
16
19
  };
17
20
  return FloatDigitUtil;
18
21
  }());
19
- export { FloatDigitUtil };
22
+ exports.FloatDigitUtil = FloatDigitUtil;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RandomNumUtil = void 0;
1
4
  /**
2
5
  * 随机数生成工具
3
6
  * @author aonaufly
@@ -34,4 +37,4 @@ var RandomNumUtil = /** @class */ (function () {
34
37
  };
35
38
  return RandomNumUtil;
36
39
  }());
37
- export { RandomNumUtil };
40
+ exports.RandomNumUtil = RandomNumUtil;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringUtil = void 0;
1
4
  /**
2
5
  * 字符串工具
3
6
  * @author aonaufly
@@ -75,4 +78,4 @@ var StringUtil = /** @class */ (function () {
75
78
  };
76
79
  return StringUtil;
77
80
  }());
78
- export { StringUtil };
81
+ exports.StringUtil = StringUtil;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniqueIDUtil = void 0;
1
4
  /**
2
5
  * 唯一ID生成器
3
6
  * @author Aonaufly
@@ -15,4 +18,4 @@ var UniqueIDUtil = /** @class */ (function () {
15
18
  };
16
19
  return UniqueIDUtil;
17
20
  }());
18
- export { UniqueIDUtil };
21
+ exports.UniqueIDUtil = UniqueIDUtil;
package/package.json CHANGED
@@ -1,28 +1,9 @@
1
1
  {
2
2
  "name": "light-h5-core-lib",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "light core lib",
5
5
  "main": "./LightCore.js",
6
6
  "types": "./type/index.d.ts",
7
- "files": [
8
- "./type/index.d.ts",
9
- "./LightCore.js",
10
- "./common/**/*.js",
11
- "./pool/pool.js"
12
- ],
13
- "exports": {
14
- ".": {
15
- "types": {
16
- "require": "./type/index.d.ts",
17
- "import": "./type/index.d.ts",
18
- "default": "./type/index.d.ts"
19
- },
20
- "import": {
21
- "import": "./LightCore.js",
22
- "default": "./LightCore.js"
23
- }
24
- }
25
- },
26
7
  "scripts": {
27
8
  "test": "echo \"Error: no test specified\" && exit 1"
28
9
  },
@@ -0,0 +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;