light-h5-core-lib 2.2.0 → 2.3.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.
Files changed (2) hide show
  1. package/package.json +7 -1
  2. package/pool/PoolObj.js +0 -76
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "light-h5-core-lib",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "light core lib",
5
5
  "main": "./Main.js",
6
6
  "types": "./type/index.d.ts",
7
+ "files": [
8
+ "./type/index.d.ts",
9
+ "./Main.js",
10
+ "./common/**/*.js",
11
+ "./pool/pool.js"
12
+ ],
7
13
  "scripts": {
8
14
  "test": "echo \"Error: no test specified\" && exit 1"
9
15
  },
package/pool/PoolObj.js DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- * 对象池(泛型)
3
- * @author aonaufly
4
- */
5
- var PoolObj = /** @class */ (function () {
6
- /**
7
- * @param cup 容量
8
- */
9
- function PoolObj(cup) {
10
- if (cup === void 0) { cup = 5; }
11
- this._cup = cup;
12
- this._pool = [];
13
- }
14
- PoolObj.prototype.put = function (obj) {
15
- if (!obj || this._pool.length >= this._cup)
16
- return false;
17
- this._pool.push(obj);
18
- return true;
19
- };
20
- PoolObj.prototype.one = function () {
21
- if (this._pool.length == 0)
22
- return null;
23
- return this._pool.shift();
24
- };
25
- Object.defineProperty(PoolObj.prototype, "cup", {
26
- /**
27
- * 获取容量(容积)
28
- */
29
- get: function () {
30
- return this._cup;
31
- },
32
- enumerable: false,
33
- configurable: true
34
- });
35
- Object.defineProperty(PoolObj.prototype, "size", {
36
- /**
37
- * 获取当前数量(已经保存的元素个数)
38
- */
39
- get: function () {
40
- if (!this._pool)
41
- return 0;
42
- return this._pool.length;
43
- },
44
- enumerable: false,
45
- configurable: true
46
- });
47
- /**
48
- * 清理对象池
49
- */
50
- PoolObj.prototype.clear = function () {
51
- if (!this._pool)
52
- return;
53
- if (this._pool.length == 0)
54
- return;
55
- var obj;
56
- for (var i = 0, j = this._pool.length; i < j; i++) {
57
- obj = this._pool[i];
58
- if (obj.destroy) {
59
- obj.destroy();
60
- }
61
- else if (obj.onDestroy) {
62
- obj.onDestroy();
63
- }
64
- obj = null;
65
- }
66
- this._pool.length = 0;
67
- };
68
- PoolObj.prototype.destroy = function (isCleared) {
69
- if (!isCleared) {
70
- this.clear();
71
- }
72
- this._pool && (this._pool = null);
73
- };
74
- return PoolObj;
75
- }());
76
- export { PoolObj };