@vope/utils 1.6.0-bate.5 → 1.6.0-bate.7
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/dist/clamp.js +31 -0
- package/dist/classnames.js +37 -0
- package/dist/compare/version.js +35 -0
- package/dist/compare/weak-equal.js +53 -0
- package/dist/convert/json.js +27 -0
- package/dist/convert/object.js +27 -0
- package/dist/convert/strings.js +27 -0
- package/dist/desens.js +71 -0
- package/dist/encoding.js +76 -0
- package/dist/index.js +81 -1243
- package/dist/input-regex.js +28 -0
- package/dist/is/class.js +42 -0
- package/dist/is/empty.js +25 -0
- package/dist/is/key.js +24 -0
- package/dist/is/null.js +24 -0
- package/dist/load/image.js +31 -0
- package/dist/memory/basic.js +187 -0
- package/dist/memory/list.js +32 -0
- package/dist/memory/power.js +33 -0
- package/dist/memory/simple.js +114 -0
- package/dist/memory/type.d.ts +11 -0
- package/dist/neo4j-anchors.js +189 -0
- package/dist/neo4j.js +181 -0
- package/dist/once.js +28 -0
- package/dist/parse/num.js +51 -0
- package/dist/power/decon.js +42 -0
- package/dist/rotate/angle.js +25 -0
- package/dist/rotate/rad.js +31 -0
- package/dist/serialize/url-params.js +73 -0
- package/dist/style/css.js +45 -0
- package/dist/subscriber.js +84 -0
- package/dist/table/flex.js +116 -0
- package/dist/union.js +67 -0
- package/dist/url/join.js +29 -0
- package/dist/url/params.js +28 -0
- package/dist/wait.js +24 -0
- package/package.json +1 -1
- package/sub_storage/offline.js +15 -17
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var input_regex_exports = {};
|
|
20
|
+
__export(input_regex_exports, {
|
|
21
|
+
inputRegex: () => inputRegex
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(input_regex_exports);
|
|
24
|
+
const RE_REGEX = /[$()*+.[?\\^{|]/g;
|
|
25
|
+
const RE_STRING = /[$()*+.[?\\^{|-]/g;
|
|
26
|
+
function inputRegex(text, flags) {
|
|
27
|
+
return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
|
|
28
|
+
}
|
package/dist/is/class.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var class_exports = {};
|
|
20
|
+
__export(class_exports, {
|
|
21
|
+
isClass: () => isClass
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(class_exports);
|
|
24
|
+
const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
|
|
25
|
+
const re_function = /^function\s+[A-Z]/;
|
|
26
|
+
const re_this = /\b\(this\b|\bthis[\.\[]\b/;
|
|
27
|
+
const re_check = /classCallCheck\(this/;
|
|
28
|
+
const re_default = /^function\sdefault_\d+\s*\(/;
|
|
29
|
+
const isClass = (value, strict = true) => {
|
|
30
|
+
if (typeof value !== "function") return false;
|
|
31
|
+
const proto = value.prototype;
|
|
32
|
+
if (!proto || proto.constructor !== value) return false;
|
|
33
|
+
const str = value.toString();
|
|
34
|
+
if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2) return true;
|
|
35
|
+
if (re_anonymous.test(str)) return false;
|
|
36
|
+
if (strict && re_function.test(str)) return true;
|
|
37
|
+
if (re_this.test(str)) {
|
|
38
|
+
if (!strict || re_check.test(str)) return true;
|
|
39
|
+
return re_default.test(str);
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
};
|
package/dist/is/empty.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var empty_exports = {};
|
|
20
|
+
__export(empty_exports, {
|
|
21
|
+
isEmpty: () => isEmpty
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(empty_exports);
|
|
24
|
+
var import_null = require("./null");
|
|
25
|
+
const isEmpty = (value) => (0, import_null.isNull)(value) || value === "";
|
package/dist/is/key.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var key_exports = {};
|
|
20
|
+
__export(key_exports, {
|
|
21
|
+
isKey: () => isKey
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(key_exports);
|
|
24
|
+
const isKey = (key, data) => key in data;
|
package/dist/is/null.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var null_exports = {};
|
|
20
|
+
__export(null_exports, {
|
|
21
|
+
isNull: () => isNull
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(null_exports);
|
|
24
|
+
const isNull = (value) => value === void 0 || value === null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var image_exports = {};
|
|
20
|
+
__export(image_exports, {
|
|
21
|
+
loadImage: () => loadImage
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(image_exports);
|
|
24
|
+
const loadImage = (src) => {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const img = new Image();
|
|
27
|
+
img.onload = () => resolve(img);
|
|
28
|
+
img.onerror = () => resolve(null);
|
|
29
|
+
img.src = src;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var basic_exports = {};
|
|
20
|
+
__export(basic_exports, {
|
|
21
|
+
MemoryBasic: () => MemoryBasic
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(basic_exports);
|
|
24
|
+
var import_strings = require("../convert/strings");
|
|
25
|
+
class MemoryBasic {
|
|
26
|
+
/**
|
|
27
|
+
* @param key 用于对数据进行分类的key
|
|
28
|
+
* @param config
|
|
29
|
+
*/
|
|
30
|
+
constructor(key, config) {
|
|
31
|
+
this.key = key;
|
|
32
|
+
this.#mount = config.mount;
|
|
33
|
+
this.#reflex = config.reflex;
|
|
34
|
+
}
|
|
35
|
+
#mount;
|
|
36
|
+
#reflex;
|
|
37
|
+
list = [];
|
|
38
|
+
memorys = /* @__PURE__ */ new Map();
|
|
39
|
+
/**
|
|
40
|
+
* 返回存储长度
|
|
41
|
+
*/
|
|
42
|
+
get size() {
|
|
43
|
+
return this.list.length;
|
|
44
|
+
}
|
|
45
|
+
getType(data) {
|
|
46
|
+
const { key } = this;
|
|
47
|
+
return typeof key === "function" ? key(data) : data[key];
|
|
48
|
+
}
|
|
49
|
+
push(...list) {
|
|
50
|
+
const { memorys } = this;
|
|
51
|
+
list.forEach((data) => {
|
|
52
|
+
const type = this.getType(data);
|
|
53
|
+
const memory = memorys.get(type);
|
|
54
|
+
const index = this.list.push(data) - 1;
|
|
55
|
+
const result = this.#mount(index, memory);
|
|
56
|
+
memory === result || memorys.set(type, result);
|
|
57
|
+
});
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 返回位于指定索引处的项
|
|
62
|
+
*/
|
|
63
|
+
at(index) {
|
|
64
|
+
const { list } = this;
|
|
65
|
+
if (index < 0) {
|
|
66
|
+
index += list.length;
|
|
67
|
+
}
|
|
68
|
+
return this.list.at(index);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 遍历所有存储数据(按入栈顺序)
|
|
72
|
+
*/
|
|
73
|
+
forEach(callback) {
|
|
74
|
+
this.list.forEach(callback);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 遍历所有存储类型
|
|
79
|
+
*/
|
|
80
|
+
forType(callback) {
|
|
81
|
+
const { memorys, list } = this;
|
|
82
|
+
for (const [type, memory] of memorys) {
|
|
83
|
+
const caches = this.#reflex(memory).map((index) => list[index]);
|
|
84
|
+
callback(caches, type);
|
|
85
|
+
}
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* some(按入栈顺序)
|
|
90
|
+
*/
|
|
91
|
+
some(callback) {
|
|
92
|
+
return this.list.some(callback);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* map(按入栈顺序)
|
|
96
|
+
*/
|
|
97
|
+
map(callback) {
|
|
98
|
+
return this.list.map(callback);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* reduce(按入栈顺序)
|
|
102
|
+
*/
|
|
103
|
+
reduce(callback, initialValue) {
|
|
104
|
+
return this.list.reduce(callback, initialValue);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 判断存储是否包含指定类型
|
|
108
|
+
*/
|
|
109
|
+
includes(type) {
|
|
110
|
+
return this.memorys.has(type);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 获取指定类型存储数据
|
|
114
|
+
*/
|
|
115
|
+
get(type) {
|
|
116
|
+
const memory = this.memorys.get(type);
|
|
117
|
+
return memory === void 0 ? null : this.#reflex(memory).map((count) => this.list[count]);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 删除指定存储数据
|
|
121
|
+
*/
|
|
122
|
+
delete(data) {
|
|
123
|
+
const { memorys, list } = this;
|
|
124
|
+
let index = -1;
|
|
125
|
+
if (!list.some((value, i) => {
|
|
126
|
+
if (data === value) {
|
|
127
|
+
index = i;
|
|
128
|
+
list.splice(index, 1);
|
|
129
|
+
const type = this.getType(value);
|
|
130
|
+
const memory = this.#reflex(memorys.get(type));
|
|
131
|
+
if (memory.length === 1) {
|
|
132
|
+
memorys.delete(type);
|
|
133
|
+
} else {
|
|
134
|
+
memory.some((count, j) => {
|
|
135
|
+
if (count === i) {
|
|
136
|
+
memory.splice(j, 1);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
})) return this;
|
|
144
|
+
for (const [type, target] of memorys) {
|
|
145
|
+
const memory = this.#reflex(target);
|
|
146
|
+
memory.forEach((value, i) => {
|
|
147
|
+
if (value >= index) {
|
|
148
|
+
memory[i] = value - 1;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (memory !== target) {
|
|
152
|
+
let reactor;
|
|
153
|
+
memory.forEach((count) => {
|
|
154
|
+
reactor = this.#mount(count, reactor);
|
|
155
|
+
});
|
|
156
|
+
memorys.set(type, reactor);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 删除指定类型存储数据
|
|
163
|
+
*/
|
|
164
|
+
deleteType(type) {
|
|
165
|
+
const { memorys, list } = this;
|
|
166
|
+
if (!memorys.has(type)) return this;
|
|
167
|
+
const local = (0, import_strings.hash8strings)(this.#reflex(memorys.get(type)));
|
|
168
|
+
const Memory = this.constructor;
|
|
169
|
+
const imitator = new Memory(this.key, {
|
|
170
|
+
mount: this.#mount,
|
|
171
|
+
reflex: this.#reflex
|
|
172
|
+
});
|
|
173
|
+
list.forEach((data, index) => {
|
|
174
|
+
index in local || imitator.push(data);
|
|
175
|
+
});
|
|
176
|
+
this.list = imitator.list;
|
|
177
|
+
this.memorys = imitator.memorys;
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 清理存储
|
|
182
|
+
*/
|
|
183
|
+
clear() {
|
|
184
|
+
this.list = [];
|
|
185
|
+
this.memorys.clear();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var list_exports = {};
|
|
20
|
+
__export(list_exports, {
|
|
21
|
+
MemoryList: () => MemoryList
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(list_exports);
|
|
24
|
+
var import_basic = require("./basic");
|
|
25
|
+
class MemoryList extends import_basic.MemoryBasic {
|
|
26
|
+
constructor(key) {
|
|
27
|
+
super(key, {
|
|
28
|
+
mount: (index, reactor) => reactor ? (reactor.push(index), reactor) : [index],
|
|
29
|
+
reflex: (reactor) => reactor
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var power_exports = {};
|
|
20
|
+
__export(power_exports, {
|
|
21
|
+
MemoryPower: () => MemoryPower
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(power_exports);
|
|
24
|
+
var import_decon = require("../power/decon");
|
|
25
|
+
var import_basic = require("./basic");
|
|
26
|
+
class MemoryPower extends import_basic.MemoryBasic {
|
|
27
|
+
constructor(key) {
|
|
28
|
+
super(key, {
|
|
29
|
+
mount: (index, reactor) => (reactor || 0) + 2 ** index,
|
|
30
|
+
reflex: (reactor) => (0, import_decon.deconPowersSum)(reactor, "asc")
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var simple_exports = {};
|
|
20
|
+
__export(simple_exports, {
|
|
21
|
+
MemorySimple: () => MemorySimple
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(simple_exports);
|
|
24
|
+
var import_basic = require("./basic");
|
|
25
|
+
class MemorySimple {
|
|
26
|
+
#memory;
|
|
27
|
+
#key;
|
|
28
|
+
get size() {
|
|
29
|
+
return this.#memory.size;
|
|
30
|
+
}
|
|
31
|
+
constructor(key) {
|
|
32
|
+
this.#key = key;
|
|
33
|
+
this.#memory = new import_basic.MemoryBasic(key, {
|
|
34
|
+
mount: (index) => index,
|
|
35
|
+
reflex: (reactor) => [reactor]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
#getType(data) {
|
|
39
|
+
const key = this.#key;
|
|
40
|
+
return typeof key === "function" ? key(data) : data[key];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 返回位于指定索引处的项
|
|
44
|
+
*/
|
|
45
|
+
at(index) {
|
|
46
|
+
return this.#memory.at(index);
|
|
47
|
+
}
|
|
48
|
+
push(...list) {
|
|
49
|
+
const memory = this.#memory;
|
|
50
|
+
list.forEach((data) => {
|
|
51
|
+
memory.includes(this.#getType(data)) || memory.push(data);
|
|
52
|
+
});
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 获取指定类型存储数据
|
|
57
|
+
*/
|
|
58
|
+
get(type) {
|
|
59
|
+
const value = this.#memory.get(type);
|
|
60
|
+
if (value === null) return value;
|
|
61
|
+
return value.length ? value[0] : null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 遍历所有存储数据(按入栈顺序)
|
|
65
|
+
*/
|
|
66
|
+
forEach(callback) {
|
|
67
|
+
this.#memory.forEach(callback);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* some(按入栈顺序)
|
|
72
|
+
*/
|
|
73
|
+
some(callback) {
|
|
74
|
+
return this.#memory.some(callback);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* map(按入栈顺序)
|
|
78
|
+
*/
|
|
79
|
+
map(callback) {
|
|
80
|
+
return this.#memory.map(callback);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* reduce(按入栈顺序)
|
|
84
|
+
*/
|
|
85
|
+
reduce(callback, initialValue) {
|
|
86
|
+
return this.#memory.reduce(callback, initialValue);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 判断是否包含指定类型
|
|
90
|
+
*/
|
|
91
|
+
includes(type) {
|
|
92
|
+
return this.#memory.includes(type);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 删除指定存储数据
|
|
96
|
+
*/
|
|
97
|
+
delete(data) {
|
|
98
|
+
this.#memory.delete(data);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 删除指定类型存储数据
|
|
103
|
+
*/
|
|
104
|
+
deleteType(type) {
|
|
105
|
+
this.#memory.deleteType(type);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 清理存储
|
|
110
|
+
*/
|
|
111
|
+
clear() {
|
|
112
|
+
this.#memory.clear();
|
|
113
|
+
}
|
|
114
|
+
}
|