baja-lite 1.0.5 → 1.0.6
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/cjs/boot-remote.d.ts +2 -2
- package/cjs/code.js +19 -5
- package/cjs/convert-xml.js +3 -2
- package/cjs/fn.js +3 -3
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +1 -0
- package/cjs/list.d.ts +10 -0
- package/cjs/list.js +36 -0
- package/cjs/object.js +4 -4
- package/cjs/set-ex.d.ts +41 -15
- package/cjs/set-ex.js +68 -52
- package/cjs/sql.d.ts +391 -193
- package/cjs/sql.js +580 -287
- package/cjs/test-mysql.d.ts +1 -0
- package/cjs/test-mysql.js +15 -2
- package/es/boot-remote.d.ts +2 -2
- package/es/code.js +19 -5
- package/es/convert-xml.js +3 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/list.d.ts +10 -0
- package/es/list.js +32 -0
- package/es/object.js +1 -1
- package/es/set-ex.d.ts +41 -15
- package/es/set-ex.js +68 -52
- package/es/sql.d.ts +391 -193
- package/es/sql.js +569 -277
- package/es/test-mysql.d.ts +1 -0
- package/es/test-mysql.js +15 -3
- package/package.json +8 -6
- package/src/boot-remote.ts +2 -2
- package/src/code.ts +24 -8
- package/src/convert-xml.ts +3 -2
- package/src/index.ts +2 -1
- package/src/list.ts +31 -0
- package/src/object.ts +3 -2
- package/src/set-ex.ts +91 -70
- package/src/sql.ts +647 -318
- package/src/test-mysql.ts +28 -9
package/cjs/boot-remote.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const BootRomote: (options:
|
|
1
|
+
import { GlobalSqlOptionForWeb } from './sql';
|
|
2
|
+
export declare const BootRomote: (options: GlobalSqlOptionForWeb) => Promise<void>;
|
package/cjs/code.js
CHANGED
|
@@ -79,6 +79,7 @@ console.log(`
|
|
|
79
79
|
"s": ["entity", "controller", "service", "sql", "module"]
|
|
80
80
|
},
|
|
81
81
|
"output": "{ClassName}Module",
|
|
82
|
+
"id"? : "uuidShort: true, notNull: true, uuid: true"
|
|
82
83
|
}
|
|
83
84
|
command是生成命令,这里声明命令同时定义文件生成路径:可用下面的变量替换.同时必须有同名模板.
|
|
84
85
|
路径是相对于项目根目录的
|
|
@@ -92,16 +93,18 @@ console.log(`
|
|
|
92
93
|
请在项目根目录的code-template添加模板文件, 按照mustache(标签定义成了[ '<%', '%>' ])进行格式化,变量:
|
|
93
94
|
title,
|
|
94
95
|
|
|
95
|
-
tableName,
|
|
96
|
-
className,
|
|
97
|
-
ClassName,
|
|
98
|
-
vueName,
|
|
99
|
-
splitName,
|
|
96
|
+
tableName, event_main_info
|
|
97
|
+
className, eventMainInfo
|
|
98
|
+
ClassName, EventMainInfo
|
|
99
|
+
vueName, event-main-info
|
|
100
|
+
splitName, event/main/info
|
|
101
|
+
SplitName, event/mainInfo
|
|
100
102
|
|
|
101
103
|
columns: [
|
|
102
104
|
comment:
|
|
103
105
|
name: sku_id
|
|
104
106
|
Name: skuId
|
|
107
|
+
NAME: SkuId
|
|
105
108
|
Field
|
|
106
109
|
Type
|
|
107
110
|
], Field(类型string),表示字段的注解, Type 表示JS类型
|
|
@@ -198,9 +201,13 @@ try {
|
|
|
198
201
|
if (r.notNull === true) {
|
|
199
202
|
fields.push(`notNull:true`);
|
|
200
203
|
}
|
|
204
|
+
if (r.id === true && configData.id) {
|
|
205
|
+
fields.push(configData.id);
|
|
206
|
+
}
|
|
201
207
|
r.Type = lxMap[r.type];
|
|
202
208
|
r.Field = `@Field({${fields.join(',')}})`;
|
|
203
209
|
r.Name = r.name.replace(/_(\w)/g, (a, b) => b.toUpperCase());
|
|
210
|
+
r.NAME = r.Name.replace(/\w/, (v) => v.toUpperCase());
|
|
204
211
|
return r;
|
|
205
212
|
});
|
|
206
213
|
conn.release();
|
|
@@ -223,6 +230,7 @@ try {
|
|
|
223
230
|
const ClassName = className.replace(/\w/, (v) => v.toUpperCase());
|
|
224
231
|
const vueName = tableName.replace(/_/g, '-');
|
|
225
232
|
const splitName = tableName.replace(/_/g, '/');
|
|
233
|
+
const SplitName = tableName.replace(/_/, '/').replace(/_(\w)/g, (a, b) => b.toUpperCase());
|
|
226
234
|
const data = {
|
|
227
235
|
title,
|
|
228
236
|
tableName,
|
|
@@ -230,16 +238,22 @@ try {
|
|
|
230
238
|
ClassName,
|
|
231
239
|
vueName,
|
|
232
240
|
splitName,
|
|
241
|
+
SplitName,
|
|
233
242
|
columns,
|
|
234
243
|
columnNames: columns?.map(i => i.name),
|
|
244
|
+
ColumnNames: columns?.map(i => i.Name),
|
|
235
245
|
columnNames_join: columns?.map(i => i.name).join(','),
|
|
236
246
|
ColumnNames_join: columns?.map(i => `${i.name} ${i.Name}`).join(','),
|
|
237
247
|
columns_no_id: columns?.filter(i => !i.id),
|
|
238
248
|
columnNames_no_id: columns?.filter(i => !i.id).map(i => i.name),
|
|
249
|
+
ColumnNames_no_id: columns?.filter(i => !i.id).map(i => i.Name),
|
|
239
250
|
columnNames_no_id_join: columns?.filter(i => !i.id).map(i => i.name).join(','),
|
|
251
|
+
ColumnNames_no_id_join: columns?.filter(i => !i.id).map(i => i.Name).join(','),
|
|
240
252
|
ids: columns?.filter(i => i.id),
|
|
241
253
|
idNames: columns?.filter(i => i.id).map(i => i.name),
|
|
254
|
+
IdNames: columns?.filter(i => i.id).map(i => i.Name),
|
|
242
255
|
idNames_join: columns?.filter(i => i.id).map(i => i.name).join(','),
|
|
256
|
+
IdNames_join: columns?.filter(i => i.id).map(i => i.Name).join(','),
|
|
243
257
|
modelName,
|
|
244
258
|
modelPath
|
|
245
259
|
};
|
package/cjs/convert-xml.js
CHANGED
|
@@ -128,8 +128,9 @@ const convertIf = function (children, param, parentIds, myBatisMapper) {
|
|
|
128
128
|
evalString = evalString.replace(/ and /gi, ' && ');
|
|
129
129
|
evalString = evalString.replace(/ or /gi, ' || ');
|
|
130
130
|
// replace == to === for strict evaluate
|
|
131
|
-
|
|
132
|
-
evalString = evalString.replace(
|
|
131
|
+
// TODO: fix != null & != ''
|
|
132
|
+
// evalString = evalString.replace(/==/g, '===');
|
|
133
|
+
// evalString = evalString.replace(/!=/g, '!==');
|
|
133
134
|
evalString = evalString.replace(/^'(.*?)'\.equalsIgnoreCase\( ([a-zA-Z]+\.[a-zA-Z]+) \)/i, `($2 && $2.toUpperCase() === '$1'.toUpperCase())`);
|
|
134
135
|
evalString = evalString.replace(/\('(.*?)'\.equalsIgnoreCase\( ([a-zA-Z]+\.[a-zA-Z]+) \)/i, `(($2 && $2.toUpperCase() === '$1'.toUpperCase())`);
|
|
135
136
|
}
|
package/cjs/fn.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ExcuteSplitMode = exports.sleep = exports.promise = void 0;
|
|
4
|
+
exports.dieTrying = dieTrying;
|
|
5
|
+
exports.excuteSplit = excuteSplit;
|
|
4
6
|
const object_1 = require("./object");
|
|
5
7
|
const error_1 = require("./error");
|
|
6
8
|
/**
|
|
@@ -74,7 +76,6 @@ async function dieTrying(fn, { ifFinish = (result) => !!result, maxTryTimes = 20
|
|
|
74
76
|
}
|
|
75
77
|
return result;
|
|
76
78
|
}
|
|
77
|
-
exports.dieTrying = dieTrying;
|
|
78
79
|
var ExcuteSplitMode;
|
|
79
80
|
(function (ExcuteSplitMode) {
|
|
80
81
|
ExcuteSplitMode[ExcuteSplitMode["SyncTrust"] = 0] = "SyncTrust";
|
|
@@ -166,4 +167,3 @@ function excuteSplit(sync, datas, fn, { everyLength = 0, groupCount = 0, settled
|
|
|
166
167
|
return reasons;
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
|
-
exports.excuteSplit = excuteSplit;
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
package/cjs/list.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class ArrayList<T> extends Array<T> {
|
|
2
|
+
constructor(array?: Array<T> | T | undefined);
|
|
3
|
+
add(...items: T[]): void;
|
|
4
|
+
size(): number;
|
|
5
|
+
isEmpty(): boolean;
|
|
6
|
+
get(index: number): T | undefined;
|
|
7
|
+
clear(): void;
|
|
8
|
+
set(index: number, item: T): void;
|
|
9
|
+
remove(index: number): void;
|
|
10
|
+
}
|
package/cjs/list.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayList = void 0;
|
|
4
|
+
class ArrayList extends Array {
|
|
5
|
+
constructor(array) {
|
|
6
|
+
super();
|
|
7
|
+
if (array instanceof Array) {
|
|
8
|
+
super.push(...array);
|
|
9
|
+
}
|
|
10
|
+
else if (typeof array !== 'undefined') {
|
|
11
|
+
super.push(array);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
add(...items) {
|
|
15
|
+
this.push(...items);
|
|
16
|
+
}
|
|
17
|
+
size() {
|
|
18
|
+
return this.length;
|
|
19
|
+
}
|
|
20
|
+
isEmpty() {
|
|
21
|
+
return this.length === 0;
|
|
22
|
+
}
|
|
23
|
+
get(index) {
|
|
24
|
+
return this[index];
|
|
25
|
+
}
|
|
26
|
+
clear() {
|
|
27
|
+
this.length = 0;
|
|
28
|
+
}
|
|
29
|
+
set(index, item) {
|
|
30
|
+
this[index] = item;
|
|
31
|
+
}
|
|
32
|
+
remove(index) {
|
|
33
|
+
this.splice(index, 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ArrayList = ArrayList;
|
package/cjs/object.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.C2P = exports.P2C = exports.arraySplit = exports.array2map = exports.mixList = exports.mixArray = exports.fixEmptyPrototy = exports.coverComplexBean = exports.createBeanFromArray = exports.emptyBean = exports.convertBeans = exports.convertBean = exports.copyBean = void 0;
|
|
7
|
+
exports.C2P2 = C2P2;
|
|
8
|
+
exports.P2C2 = P2C2;
|
|
7
9
|
const iterare_1 = __importDefault(require("iterare"));
|
|
8
10
|
/**
|
|
9
11
|
* 对象对象(等同与convertBean)
|
|
@@ -214,7 +216,7 @@ const P2CEX = /[A-Z]/g;
|
|
|
214
216
|
const P2C = (pro, IF = true) => IF ? pro.replace(P2CEX, (a) => `_${a.toLowerCase()}`) : pro;
|
|
215
217
|
exports.P2C = P2C;
|
|
216
218
|
const C2PEX = /_([a-z])/g;
|
|
217
|
-
const C2P = (pro, IF = true) => IF ? pro.replace(C2PEX, (a, b) =>
|
|
219
|
+
const C2P = (pro, IF = true) => IF ? pro.replace(C2PEX, (a, b) => `${b.toUpperCase()}`) : pro;
|
|
218
220
|
exports.C2P = C2P;
|
|
219
221
|
function C2P2(datas) {
|
|
220
222
|
if (datas instanceof Array) {
|
|
@@ -227,7 +229,6 @@ function C2P2(datas) {
|
|
|
227
229
|
return datas;
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
|
-
exports.C2P2 = C2P2;
|
|
231
232
|
function P2C2(datas) {
|
|
232
233
|
if (datas instanceof Array) {
|
|
233
234
|
return (0, iterare_1.default)(datas).map((data) => Object.fromEntries(Object.entries(data).map(([K, V]) => [(0, exports.P2C)(K), V]))).toArray();
|
|
@@ -239,4 +240,3 @@ function P2C2(datas) {
|
|
|
239
240
|
return datas;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
|
-
exports.P2C2 = P2C2;
|
package/cjs/set-ex.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare class SetEx<T> extends Set {
|
|
2
|
-
private
|
|
3
|
-
private
|
|
4
|
-
private
|
|
5
|
-
private
|
|
2
|
+
private _key;
|
|
3
|
+
private _onExist1?;
|
|
4
|
+
private _onNotExist1?;
|
|
5
|
+
private _replaceIfExits1;
|
|
6
|
+
private _onExist2?;
|
|
7
|
+
private _onNotExist2?;
|
|
8
|
+
private _replaceIfExits2;
|
|
6
9
|
/**
|
|
7
10
|
* @param key 识别是否存在的对象的属性名
|
|
8
11
|
* @param onExist 当存在时作何操作? oldData/newData 哪个将添加到set,由replaceItemWhenExits决定,默认是oldData生效
|
|
@@ -10,13 +13,22 @@ export declare class SetEx<T> extends Set {
|
|
|
10
13
|
* @param replaceWhenExits 当存在时是否覆盖?
|
|
11
14
|
* @param values 初始数组
|
|
12
15
|
*/
|
|
13
|
-
constructor(
|
|
16
|
+
constructor(option: {
|
|
14
17
|
key: keyof T;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
/** add&addAll触发 */
|
|
19
|
+
onExist1?: (oldData: T, newData: T) => void;
|
|
20
|
+
/** add&addAll触发 */
|
|
21
|
+
onNotExist1?: (newData: T) => void;
|
|
22
|
+
/** add&addAll触发 */
|
|
23
|
+
replaceIfExits1?: boolean;
|
|
24
|
+
/** add2&addAll2触发 */
|
|
25
|
+
onExist2?: (oldData: T, newData: T) => void;
|
|
26
|
+
/** add2&addAll2触发 */
|
|
27
|
+
onNotExist2?: (newData: T) => void;
|
|
28
|
+
/** add2&addAll2触发 */
|
|
29
|
+
replaceIfExits2?: boolean;
|
|
18
30
|
values?: ReadonlyArray<T> | null;
|
|
19
|
-
}
|
|
31
|
+
});
|
|
20
32
|
/**
|
|
21
33
|
*
|
|
22
34
|
* 添加返回
|
|
@@ -117,11 +129,21 @@ export declare class SetEx<T> extends Set {
|
|
|
117
129
|
* @param {(oldData: T, newData: T) => void} [onExist]
|
|
118
130
|
* @param {boolean} [replaceWhenExits=false]
|
|
119
131
|
*/
|
|
120
|
-
reset(
|
|
132
|
+
reset(option: {
|
|
121
133
|
key?: keyof T;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
/** add&addAll触发 */
|
|
135
|
+
onExist1?: (oldData: T, newData: T) => void;
|
|
136
|
+
/** add&addAll触发 */
|
|
137
|
+
onNotExist1?: (newData: T) => void;
|
|
138
|
+
/** add&addAll触发 */
|
|
139
|
+
replaceIfExits1?: boolean;
|
|
140
|
+
/** add2&addAll2触发 */
|
|
141
|
+
onExist2?: (oldData: T, newData: T) => void;
|
|
142
|
+
/** add2&addAll2触发 */
|
|
143
|
+
onNotExist2?: (newData: T) => void;
|
|
144
|
+
/** add2&addAll2触发 */
|
|
145
|
+
replaceIfExits2?: boolean;
|
|
146
|
+
values?: ReadonlyArray<T> | null;
|
|
125
147
|
}): this;
|
|
126
148
|
/**
|
|
127
149
|
*
|
|
@@ -165,7 +187,11 @@ export declare class SetEx<T> extends Set {
|
|
|
165
187
|
name: T[keyof T];
|
|
166
188
|
}[];
|
|
167
189
|
};
|
|
168
|
-
set
|
|
190
|
+
set onExist1(onExist1: ((oldData: T, newData: T) => void) | undefined);
|
|
191
|
+
set onExist2(onExist2: ((oldData: T, newData: T) => void) | undefined);
|
|
192
|
+
set onNotExist1(onNotExist1: ((newData: T) => void) | undefined);
|
|
193
|
+
set onNotExist2(onNotExist2: ((newData: T) => void) | undefined);
|
|
194
|
+
set replaceIfExits1(replaceIfExits1: boolean);
|
|
195
|
+
set replaceIfExits2(replaceIfExits2: boolean);
|
|
169
196
|
set key(key: keyof T);
|
|
170
|
-
set replaceWhenExits(replaceWhenExits: boolean);
|
|
171
197
|
}
|
package/cjs/set-ex.js
CHANGED
|
@@ -9,25 +9,17 @@ class SetEx extends Set {
|
|
|
9
9
|
* @param replaceWhenExits 当存在时是否覆盖?
|
|
10
10
|
* @param values 初始数组
|
|
11
11
|
*/
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(option) {
|
|
13
13
|
super();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else {
|
|
24
|
-
this.whenOnExist = onExist;
|
|
25
|
-
this.uniqueKey = key;
|
|
26
|
-
this.replaceItemWhenExits = replaceWhenExits;
|
|
27
|
-
this.whenOnNotExist = onNotExist;
|
|
28
|
-
if (values) {
|
|
29
|
-
this.addAll(...values);
|
|
30
|
-
}
|
|
14
|
+
this._key = option.key;
|
|
15
|
+
this._onExist1 = option.onExist1;
|
|
16
|
+
this._onNotExist1 = option.onNotExist1;
|
|
17
|
+
this._replaceIfExits1 = option.replaceIfExits1 === true;
|
|
18
|
+
this._onExist2 = option.onExist2;
|
|
19
|
+
this._onNotExist2 = option.onNotExist2;
|
|
20
|
+
this._replaceIfExits2 = option.replaceIfExits2 === true;
|
|
21
|
+
if (option.values) {
|
|
22
|
+
this.addAll(...option.values);
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
25
|
/**
|
|
@@ -39,12 +31,12 @@ class SetEx extends Set {
|
|
|
39
31
|
add(value) {
|
|
40
32
|
let flag = false;
|
|
41
33
|
this.forEach((item) => {
|
|
42
|
-
if (item[this.
|
|
34
|
+
if (item[this._key] === value[this._key]) {
|
|
43
35
|
flag = true;
|
|
44
|
-
if (this.
|
|
45
|
-
this.
|
|
36
|
+
if (this._onExist1) {
|
|
37
|
+
this._onExist1(item, value);
|
|
46
38
|
}
|
|
47
|
-
if (this.
|
|
39
|
+
if (this._replaceIfExits1 === true) {
|
|
48
40
|
super.delete(item);
|
|
49
41
|
flag = false;
|
|
50
42
|
}
|
|
@@ -53,8 +45,8 @@ class SetEx extends Set {
|
|
|
53
45
|
});
|
|
54
46
|
if (flag === false) {
|
|
55
47
|
super.add(value);
|
|
56
|
-
if (this.
|
|
57
|
-
this.
|
|
48
|
+
if (this._onNotExist1) {
|
|
49
|
+
this._onNotExist1(value);
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
return this;
|
|
@@ -80,13 +72,13 @@ class SetEx extends Set {
|
|
|
80
72
|
let flag = false;
|
|
81
73
|
let tmp = value;
|
|
82
74
|
this.forEach((item) => {
|
|
83
|
-
if (item[this.
|
|
75
|
+
if (item[this._key] === value[this._key]) {
|
|
84
76
|
flag = true;
|
|
85
|
-
if (this.
|
|
86
|
-
this.
|
|
77
|
+
if (this._onExist2) {
|
|
78
|
+
this._onExist2(item, value);
|
|
87
79
|
}
|
|
88
|
-
if (this.
|
|
89
|
-
super.delete(
|
|
80
|
+
if (this._replaceIfExits2 === true) {
|
|
81
|
+
super.delete(value);
|
|
90
82
|
flag = false;
|
|
91
83
|
}
|
|
92
84
|
else {
|
|
@@ -97,8 +89,8 @@ class SetEx extends Set {
|
|
|
97
89
|
});
|
|
98
90
|
if (flag === false) {
|
|
99
91
|
super.add(value);
|
|
100
|
-
if (this.
|
|
101
|
-
this.
|
|
92
|
+
if (this._onNotExist2) {
|
|
93
|
+
this._onNotExist2(value);
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
96
|
return tmp;
|
|
@@ -123,7 +115,7 @@ class SetEx extends Set {
|
|
|
123
115
|
*/
|
|
124
116
|
find(value) {
|
|
125
117
|
for (const item of this) {
|
|
126
|
-
if (item[this.
|
|
118
|
+
if (item[this._key] === value) {
|
|
127
119
|
return item;
|
|
128
120
|
}
|
|
129
121
|
}
|
|
@@ -137,7 +129,7 @@ class SetEx extends Set {
|
|
|
137
129
|
findAll(value) {
|
|
138
130
|
const res = new Array();
|
|
139
131
|
this.forEach((item) => {
|
|
140
|
-
if (item[this.
|
|
132
|
+
if (item[this._key] === value) {
|
|
141
133
|
res.push(item);
|
|
142
134
|
}
|
|
143
135
|
});
|
|
@@ -180,7 +172,7 @@ class SetEx extends Set {
|
|
|
180
172
|
*/
|
|
181
173
|
has(value) {
|
|
182
174
|
for (const item of this) {
|
|
183
|
-
if (item[this.
|
|
175
|
+
if (item[this._key] === value) {
|
|
184
176
|
return true;
|
|
185
177
|
}
|
|
186
178
|
}
|
|
@@ -225,7 +217,7 @@ class SetEx extends Set {
|
|
|
225
217
|
*/
|
|
226
218
|
delete(value) {
|
|
227
219
|
for (const item of this) {
|
|
228
|
-
if (item[this.
|
|
220
|
+
if (item[this._key] === value) {
|
|
229
221
|
super.delete(item);
|
|
230
222
|
return true;
|
|
231
223
|
}
|
|
@@ -239,20 +231,32 @@ class SetEx extends Set {
|
|
|
239
231
|
* @param {(oldData: T, newData: T) => void} [onExist]
|
|
240
232
|
* @param {boolean} [replaceWhenExits=false]
|
|
241
233
|
*/
|
|
242
|
-
reset(
|
|
243
|
-
|
|
244
|
-
|
|
234
|
+
reset(option) {
|
|
235
|
+
this.clear();
|
|
236
|
+
if (option.key) {
|
|
237
|
+
this._key = option.key;
|
|
245
238
|
}
|
|
246
|
-
if (
|
|
247
|
-
this.
|
|
239
|
+
if (option.onExist1) {
|
|
240
|
+
this._onExist1 = option.onExist1;
|
|
248
241
|
}
|
|
249
|
-
if (
|
|
250
|
-
this.
|
|
242
|
+
if (option.onNotExist1) {
|
|
243
|
+
this._onNotExist1 = option.onNotExist1;
|
|
251
244
|
}
|
|
252
|
-
if (
|
|
253
|
-
this.
|
|
245
|
+
if (option.replaceIfExits1) {
|
|
246
|
+
this._replaceIfExits1 = option.replaceIfExits1;
|
|
247
|
+
}
|
|
248
|
+
if (option.onExist2) {
|
|
249
|
+
this._onExist2 = option.onExist2;
|
|
250
|
+
}
|
|
251
|
+
if (option.onNotExist2) {
|
|
252
|
+
this._onNotExist2 = option.onNotExist2;
|
|
253
|
+
}
|
|
254
|
+
if (option.replaceIfExits2) {
|
|
255
|
+
this._replaceIfExits2 = option.replaceIfExits2;
|
|
256
|
+
}
|
|
257
|
+
if (option.values) {
|
|
258
|
+
this.addAll(...option.values);
|
|
254
259
|
}
|
|
255
|
-
this.clear();
|
|
256
260
|
return this;
|
|
257
261
|
}
|
|
258
262
|
/**
|
|
@@ -313,7 +317,7 @@ class SetEx extends Set {
|
|
|
313
317
|
const result = {};
|
|
314
318
|
const list = this.toArray({ sort, each, filter, map });
|
|
315
319
|
for (const item of list) {
|
|
316
|
-
const name = item[this.
|
|
320
|
+
const name = item[this._key];
|
|
317
321
|
for (const key in item) {
|
|
318
322
|
if (!result[key]) {
|
|
319
323
|
result[key] = [];
|
|
@@ -323,14 +327,26 @@ class SetEx extends Set {
|
|
|
323
327
|
}
|
|
324
328
|
return result;
|
|
325
329
|
}
|
|
326
|
-
set
|
|
327
|
-
this.
|
|
330
|
+
set onExist1(onExist1) {
|
|
331
|
+
this._onExist1 = onExist1;
|
|
328
332
|
}
|
|
329
|
-
set
|
|
330
|
-
this.
|
|
333
|
+
set onExist2(onExist2) {
|
|
334
|
+
this._onExist2 = onExist2;
|
|
335
|
+
}
|
|
336
|
+
set onNotExist1(onNotExist1) {
|
|
337
|
+
this._onNotExist1 = onNotExist1;
|
|
331
338
|
}
|
|
332
|
-
set
|
|
333
|
-
this.
|
|
339
|
+
set onNotExist2(onNotExist2) {
|
|
340
|
+
this._onNotExist2 = onNotExist2;
|
|
341
|
+
}
|
|
342
|
+
set replaceIfExits1(replaceIfExits1) {
|
|
343
|
+
this._replaceIfExits1 = replaceIfExits1;
|
|
344
|
+
}
|
|
345
|
+
set replaceIfExits2(replaceIfExits2) {
|
|
346
|
+
this._replaceIfExits2 = replaceIfExits2;
|
|
347
|
+
}
|
|
348
|
+
set key(key) {
|
|
349
|
+
this._key = key;
|
|
334
350
|
}
|
|
335
351
|
}
|
|
336
352
|
exports.SetEx = SetEx;
|