@leyyo/common 1.3.19 → 1.3.20
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/base/index.types.d.ts +67 -0
- package/dist/base/index.types.js +32 -0
- package/dist/base/leyyo.d.ts +3 -0
- package/dist/base/leyyo.js +18 -7
- package/dist/class/index.types.d.ts +20 -0
- package/dist/class/list.d.ts +6 -0
- package/dist/class/list.js +6 -0
- package/dist/class/logger.instance.d.ts +5 -0
- package/dist/class/logger.instance.js +13 -0
- package/dist/common/deploy.common.d.ts +16 -0
- package/dist/common/deploy.common.js +17 -0
- package/dist/common/enum.pool.d.ts +10 -0
- package/dist/common/enum.pool.js +14 -0
- package/dist/common/error.common.d.ts +30 -0
- package/dist/common/error.common.js +40 -0
- package/dist/common/error.pool.d.ts +9 -0
- package/dist/common/error.pool.js +10 -0
- package/dist/common/event.common.d.ts +8 -0
- package/dist/common/event.common.js +16 -3
- package/dist/common/index.types.d.ts +432 -0
- package/dist/common/index.types.js +1 -0
- package/dist/common/inert.d.ts +48 -0
- package/dist/common/inert.js +29 -0
- package/dist/common/lifecycle.common.d.ts +14 -0
- package/dist/common/lifecycle.common.js +16 -0
- package/dist/common/literal.pool.d.ts +11 -0
- package/dist/common/literal.pool.js +15 -0
- package/dist/common/log.common.d.ts +54 -0
- package/dist/common/log.common.js +96 -6
- package/dist/common/repo.common.d.ts +188 -0
- package/dist/common/repo.common.js +211 -0
- package/dist/const/index.d.ts +6 -0
- package/dist/const/index.js +7 -0
- package/dist/enum/log-level.d.ts +3 -0
- package/dist/error/caused.error.d.ts +10 -0
- package/dist/error/caused.error.js +10 -0
- package/dist/error/developer.error.d.ts +8 -0
- package/dist/error/developer.error.js +10 -0
- package/dist/error/http.error.d.ts +13 -0
- package/dist/error/http.error.js +7 -0
- package/dist/error/index.types.d.ts +149 -0
- package/dist/error/invalid-value.error.d.ts +3 -0
- package/dist/error/invalid-value.error.js +3 -0
- package/dist/error/leyyo.error.d.ts +33 -0
- package/dist/error/leyyo.error.js +36 -0
- package/dist/error/multiple.error.d.ts +6 -0
- package/dist/error/multiple.error.js +7 -0
- package/dist/function/define-loader.d.ts +6 -0
- package/dist/function/define-loader.js +6 -0
- package/dist/function/delay.d.ts +8 -0
- package/dist/function/delay.js +9 -0
- package/dist/function/delete-prop.d.ts +21 -0
- package/dist/function/delete-prop.js +22 -0
- package/dist/function/empty-fn.d.ts +6 -0
- package/dist/function/empty-fn.js +7 -0
- package/dist/function/extended-type.d.ts +6 -0
- package/dist/function/extended-type.js +7 -0
- package/dist/function/get-fqn.d.ts +6 -0
- package/dist/function/get-fqn.js +7 -0
- package/dist/function/get-prop.d.ts +21 -0
- package/dist/function/get-prop.js +21 -0
- package/dist/function/get-stat.d.ts +20 -0
- package/dist/function/has-fqn.d.ts +6 -0
- package/dist/function/has-fqn.js +7 -0
- package/dist/function/is-class.d.ts +6 -0
- package/dist/function/is-class.js +18 -0
- package/dist/function/is-empty.d.ts +11 -0
- package/dist/function/is-empty.js +11 -0
- package/dist/function/is-filled-arr.d.ts +9 -0
- package/dist/function/is-filled-arr.js +9 -0
- package/dist/function/is-filled-obj.d.ts +9 -0
- package/dist/function/is-filled-obj.js +9 -0
- package/dist/function/is-obj.d.ts +8 -0
- package/dist/function/is-obj.js +8 -0
- package/dist/function/is-test.d.ts +8 -0
- package/dist/function/is-test.js +14 -0
- package/dist/function/is-text.d.ts +10 -0
- package/dist/function/is-text.js +10 -0
- package/dist/function/jitter-interval.d.ts +9 -0
- package/dist/function/jitter-interval.js +16 -0
- package/dist/function/load-config.d.ts +19 -0
- package/dist/function/load-config.js +52 -1
- package/dist/function/on-fqn-set.js +1 -0
- package/dist/function/one-or-more.d.ts +6 -0
- package/dist/function/one-or-more.js +7 -0
- package/dist/function/opt-add.d.ts +8 -0
- package/dist/function/opt-add.js +8 -0
- package/dist/function/opt-append.d.ts +7 -0
- package/dist/function/opt-append.js +7 -0
- package/dist/function/opt-check.d.ts +6 -0
- package/dist/function/opt-check.js +7 -0
- package/dist/function/opt-clone.d.ts +6 -0
- package/dist/function/opt-clone.js +7 -0
- package/dist/function/opt-field.d.ts +8 -0
- package/dist/function/opt-field.js +8 -0
- package/dist/function/opt-fn.d.ts +6 -0
- package/dist/function/opt-fn.js +7 -0
- package/dist/function/random-test-no.d.ts +5 -0
- package/dist/function/random-test-no.js +5 -0
- package/dist/function/remove-fqn.d.ts +8 -0
- package/dist/function/remove-fqn.js +11 -1
- package/dist/function/run-exporter.d.ts +5 -0
- package/dist/function/run-exporter.js +14 -0
- package/dist/function/secure-json.d.ts +35 -0
- package/dist/function/secure-json.js +44 -0
- package/dist/function/set-anonymous-fqn.js +2 -0
- package/dist/function/set-fqn.d.ts +7 -0
- package/dist/function/set-fqn.js +8 -0
- package/dist/function/set-prop.d.ts +24 -0
- package/dist/function/set-prop.js +24 -0
- package/dist/function/stamp-loader.d.ts +6 -0
- package/dist/function/stamp-loader.js +6 -0
- package/dist/function/test-case.d.ts +7 -0
- package/dist/function/test-case.js +7 -0
- package/dist/function/test-name.d.ts +7 -0
- package/dist/function/test-name.js +7 -0
- package/dist/function/trigger-fqn.js +1 -0
- package/dist/index.foretell.js +3 -0
- package/dist/index.js +1 -0
- package/dist/index.loader.js +8 -1
- package/dist/sys/leyyo-storage.d.ts +7 -0
- package/dist/sys/leyyo-storage.js +23 -0
- package/package.json +1 -1
|
@@ -4,34 +4,222 @@ import { LeyyoLike } from "../base/index.js";
|
|
|
4
4
|
export declare class RepoCommon implements RepoCommonLike {
|
|
5
5
|
private leyyo;
|
|
6
6
|
private static _created;
|
|
7
|
+
/**
|
|
8
|
+
* Internal items which stores arrays
|
|
9
|
+
* */
|
|
7
10
|
private _arrayItems;
|
|
11
|
+
/**
|
|
12
|
+
* Internal array volatile repo which could be cleared after lifecycle run
|
|
13
|
+
* */
|
|
8
14
|
private _arrayVolatiles;
|
|
15
|
+
/**
|
|
16
|
+
* Internal items which stores lists
|
|
17
|
+
* */
|
|
9
18
|
private _listItems;
|
|
19
|
+
/**
|
|
20
|
+
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
21
|
+
* */
|
|
10
22
|
private _listVolatiles;
|
|
23
|
+
/**
|
|
24
|
+
* Internal items which stores maps
|
|
25
|
+
* */
|
|
11
26
|
private _mapItems;
|
|
27
|
+
/**
|
|
28
|
+
* Internal map volatile repo which could be cleared after lifecycle run
|
|
29
|
+
* */
|
|
12
30
|
private _mapVolatiles;
|
|
31
|
+
/**
|
|
32
|
+
* Internal items which stores sets
|
|
33
|
+
* */
|
|
13
34
|
private _setItems;
|
|
35
|
+
/**
|
|
36
|
+
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
37
|
+
* */
|
|
14
38
|
private _setVolatiles;
|
|
15
39
|
constructor(leyyo: LeyyoLike);
|
|
40
|
+
/**
|
|
41
|
+
* Create new array
|
|
42
|
+
*
|
|
43
|
+
* @param {string} name - name of collection
|
|
44
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
45
|
+
* @return {Array<any>}
|
|
46
|
+
* */
|
|
16
47
|
newArray<V>(name: string, volatile?: boolean): Array<V>;
|
|
48
|
+
/**
|
|
49
|
+
* Remove array by given key
|
|
50
|
+
*
|
|
51
|
+
* @param {symbol} key - key of collection
|
|
52
|
+
* @return {number}
|
|
53
|
+
*
|
|
54
|
+
* Return possibilities:
|
|
55
|
+
* - `-2`: key is not valid symbol
|
|
56
|
+
* - `-1`: key does not exist
|
|
57
|
+
* - `>= 0`: length of removed items in collection
|
|
58
|
+
* */
|
|
17
59
|
removeArray(key: symbol): number;
|
|
60
|
+
/**
|
|
61
|
+
* Clear array by given key
|
|
62
|
+
*
|
|
63
|
+
* @param {symbol} key - key of collection
|
|
64
|
+
* @return {number}
|
|
65
|
+
*
|
|
66
|
+
* Return possibilities:
|
|
67
|
+
* - `-2`: key is not valid symbol
|
|
68
|
+
* - `-1`: key does not exist
|
|
69
|
+
* - `>= 0`: length of cleared items in collection
|
|
70
|
+
* */
|
|
18
71
|
clearArray(key: symbol): number;
|
|
72
|
+
/**
|
|
73
|
+
* List all array keys
|
|
74
|
+
*
|
|
75
|
+
* @return {Array<symbol>}
|
|
76
|
+
* */
|
|
19
77
|
listArrays(): Array<symbol>;
|
|
78
|
+
/**
|
|
79
|
+
* Print all arrays
|
|
80
|
+
*
|
|
81
|
+
* @return {Record} - as {key: length of collection}
|
|
82
|
+
*
|
|
83
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
84
|
+
* */
|
|
20
85
|
printArrays(): Record<string, number>;
|
|
86
|
+
/**
|
|
87
|
+
* Create new list
|
|
88
|
+
*
|
|
89
|
+
* @param {string} name - name of collection
|
|
90
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
91
|
+
* @return {List<any>}
|
|
92
|
+
* */
|
|
21
93
|
newList<V>(name: string, volatile?: boolean): List<V>;
|
|
94
|
+
/**
|
|
95
|
+
* Remove list by given key
|
|
96
|
+
*
|
|
97
|
+
* @param {symbol} key - key of collection
|
|
98
|
+
* @return {number}
|
|
99
|
+
*
|
|
100
|
+
* Return possibilities:
|
|
101
|
+
* - `-2`: key is not valid symbol
|
|
102
|
+
* - `-1`: key does not exist
|
|
103
|
+
* - `>= 0`: length of removed items in collection
|
|
104
|
+
* */
|
|
22
105
|
removeList(key: symbol): number;
|
|
106
|
+
/**
|
|
107
|
+
* Clear list by given key
|
|
108
|
+
*
|
|
109
|
+
* @param {symbol} key - key of collection
|
|
110
|
+
* @return {number}
|
|
111
|
+
*
|
|
112
|
+
* Return possibilities:
|
|
113
|
+
* - `-2`: key is not valid symbol
|
|
114
|
+
* - `-1`: key does not exist
|
|
115
|
+
* - `>= 0`: length of cleared items in collection
|
|
116
|
+
* */
|
|
23
117
|
clearList(key: symbol): number;
|
|
118
|
+
/**
|
|
119
|
+
* List all list keys
|
|
120
|
+
*
|
|
121
|
+
* @return {Array<symbol>}
|
|
122
|
+
* */
|
|
24
123
|
listLists(): Array<symbol>;
|
|
124
|
+
/**
|
|
125
|
+
* Print all lists
|
|
126
|
+
*
|
|
127
|
+
* @return {Record} - as {key: length of collection}
|
|
128
|
+
*
|
|
129
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
130
|
+
* */
|
|
25
131
|
printLists(): Record<string, number>;
|
|
132
|
+
/**
|
|
133
|
+
* Create new map
|
|
134
|
+
*
|
|
135
|
+
* @param {string} name - name of collection
|
|
136
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
137
|
+
* @return {Map<any, any>}
|
|
138
|
+
* */
|
|
26
139
|
newMap<K, V>(name: string, volatile?: boolean): Map<K, V>;
|
|
140
|
+
/**
|
|
141
|
+
* Remove map by given key
|
|
142
|
+
*
|
|
143
|
+
* @param {symbol} key - key of collection
|
|
144
|
+
* @return {number}
|
|
145
|
+
*
|
|
146
|
+
* Return possibilities:
|
|
147
|
+
* - `-2`: key is not valid symbol
|
|
148
|
+
* - `-1`: key does not exist
|
|
149
|
+
* - `>= 0`: length of removed items in collection
|
|
150
|
+
* */
|
|
27
151
|
removeMap(key: symbol): number;
|
|
152
|
+
/**
|
|
153
|
+
* Clear map by given key
|
|
154
|
+
*
|
|
155
|
+
* @param {symbol} key - key of collection
|
|
156
|
+
* @return {number}
|
|
157
|
+
*
|
|
158
|
+
* Return possibilities:
|
|
159
|
+
* - `-2`: key is not valid symbol
|
|
160
|
+
* - `-1`: key does not exist
|
|
161
|
+
* - `>= 0`: length of cleared items in collection
|
|
162
|
+
* */
|
|
28
163
|
clearMap(key: symbol): number;
|
|
164
|
+
/**
|
|
165
|
+
* List all map keys
|
|
166
|
+
*
|
|
167
|
+
* @return {Array<symbol>}
|
|
168
|
+
* */
|
|
29
169
|
listMaps(): Array<symbol>;
|
|
170
|
+
/**
|
|
171
|
+
* Print all maps
|
|
172
|
+
*
|
|
173
|
+
* @return {Record} - as {key: length of collection}
|
|
174
|
+
*
|
|
175
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
176
|
+
* */
|
|
30
177
|
printMaps(): Record<string, number>;
|
|
178
|
+
/**
|
|
179
|
+
* Create new set
|
|
180
|
+
*
|
|
181
|
+
* @param {string} name - name of collection
|
|
182
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
183
|
+
* @return {Set<any>}
|
|
184
|
+
* */
|
|
31
185
|
newSet<V>(name: string, volatile?: boolean): Set<V>;
|
|
186
|
+
/**
|
|
187
|
+
* Remove set by given key
|
|
188
|
+
*
|
|
189
|
+
* @param {symbol} key - key of collection
|
|
190
|
+
* @return {number}
|
|
191
|
+
*
|
|
192
|
+
* Return possibilities:
|
|
193
|
+
* - `-2`: key is not valid symbol
|
|
194
|
+
* - `-1`: key does not exist
|
|
195
|
+
* - `>= 0`: length of removed items in collection
|
|
196
|
+
* */
|
|
32
197
|
removeSet(key: symbol): number;
|
|
198
|
+
/**
|
|
199
|
+
* Clear set by given key
|
|
200
|
+
*
|
|
201
|
+
* @param {symbol} key - key of collection
|
|
202
|
+
* @return {number}
|
|
203
|
+
*
|
|
204
|
+
* Return possibilities:
|
|
205
|
+
* - `-2`: key is not valid symbol
|
|
206
|
+
* - `-1`: key does not exist
|
|
207
|
+
* - `>= 0`: length of cleared items in collection
|
|
208
|
+
* */
|
|
33
209
|
clearSet(key: symbol): number;
|
|
210
|
+
/**
|
|
211
|
+
* List all set keys
|
|
212
|
+
*
|
|
213
|
+
* @return {Array<symbol>}
|
|
214
|
+
* */
|
|
34
215
|
listSets(): Array<symbol>;
|
|
216
|
+
/**
|
|
217
|
+
* Print all sets
|
|
218
|
+
*
|
|
219
|
+
* @return {Record} - as {key: length of collection}
|
|
220
|
+
*
|
|
221
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
222
|
+
* */
|
|
35
223
|
printSets(): Record<string, number>;
|
|
36
224
|
init(): void;
|
|
37
225
|
}
|
|
@@ -3,19 +3,49 @@ import { isText, testCase } from "../function/index.js";
|
|
|
3
3
|
import { DeveloperError } from "../error/index.js";
|
|
4
4
|
import { List } from "../class/index.js";
|
|
5
5
|
import { getRootStorage } from "../sys/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Identifier of file
|
|
8
|
+
* */
|
|
6
9
|
const where = `${FQN}.Repo`;
|
|
7
10
|
const _NAME = "$$leyyo.repo";
|
|
11
|
+
// noinspection JSUnusedGlobalSymbols
|
|
8
12
|
export class RepoCommon {
|
|
9
13
|
leyyo;
|
|
14
|
+
// region property
|
|
10
15
|
static _created;
|
|
16
|
+
/**
|
|
17
|
+
* Internal items which stores arrays
|
|
18
|
+
* */
|
|
11
19
|
_arrayItems = getRootStorage(_NAME, new Map());
|
|
20
|
+
/**
|
|
21
|
+
* Internal array volatile repo which could be cleared after lifecycle run
|
|
22
|
+
* */
|
|
12
23
|
_arrayVolatiles = getRootStorage(_NAME, new Set());
|
|
24
|
+
/**
|
|
25
|
+
* Internal items which stores lists
|
|
26
|
+
* */
|
|
13
27
|
_listItems = getRootStorage(_NAME, new Map());
|
|
28
|
+
/**
|
|
29
|
+
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
30
|
+
* */
|
|
14
31
|
_listVolatiles = getRootStorage(_NAME, new Set());
|
|
32
|
+
/**
|
|
33
|
+
* Internal items which stores maps
|
|
34
|
+
* */
|
|
15
35
|
_mapItems = getRootStorage(_NAME, new Map());
|
|
36
|
+
/**
|
|
37
|
+
* Internal map volatile repo which could be cleared after lifecycle run
|
|
38
|
+
* */
|
|
16
39
|
_mapVolatiles = getRootStorage(_NAME, new Set());
|
|
40
|
+
/**
|
|
41
|
+
* Internal items which stores sets
|
|
42
|
+
* */
|
|
17
43
|
_setItems = getRootStorage(_NAME, new Map());
|
|
44
|
+
/**
|
|
45
|
+
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
46
|
+
* */
|
|
18
47
|
_setVolatiles = getRootStorage(_NAME, new Set());
|
|
48
|
+
// endregion property
|
|
19
49
|
constructor(leyyo) {
|
|
20
50
|
this.leyyo = leyyo;
|
|
21
51
|
if (RepoCommon._created) {
|
|
@@ -23,6 +53,14 @@ export class RepoCommon {
|
|
|
23
53
|
}
|
|
24
54
|
RepoCommon._created = true;
|
|
25
55
|
}
|
|
56
|
+
// region array
|
|
57
|
+
/**
|
|
58
|
+
* Create new array
|
|
59
|
+
*
|
|
60
|
+
* @param {string} name - name of collection
|
|
61
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
62
|
+
* @return {Array<any>}
|
|
63
|
+
* */
|
|
26
64
|
newArray(name, volatile) {
|
|
27
65
|
if (!isText(name)) {
|
|
28
66
|
throw new DeveloperError("Invalid repository array name", testCase(FQN, 140), where);
|
|
@@ -35,6 +73,17 @@ export class RepoCommon {
|
|
|
35
73
|
}
|
|
36
74
|
return item;
|
|
37
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Remove array by given key
|
|
78
|
+
*
|
|
79
|
+
* @param {symbol} key - key of collection
|
|
80
|
+
* @return {number}
|
|
81
|
+
*
|
|
82
|
+
* Return possibilities:
|
|
83
|
+
* - `-2`: key is not valid symbol
|
|
84
|
+
* - `-1`: key does not exist
|
|
85
|
+
* - `>= 0`: length of removed items in collection
|
|
86
|
+
* */
|
|
38
87
|
removeArray(key) {
|
|
39
88
|
const cleared = this.clearArray(key);
|
|
40
89
|
if (cleared >= 0) {
|
|
@@ -45,6 +94,17 @@ export class RepoCommon {
|
|
|
45
94
|
}
|
|
46
95
|
return cleared;
|
|
47
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Clear array by given key
|
|
99
|
+
*
|
|
100
|
+
* @param {symbol} key - key of collection
|
|
101
|
+
* @return {number}
|
|
102
|
+
*
|
|
103
|
+
* Return possibilities:
|
|
104
|
+
* - `-2`: key is not valid symbol
|
|
105
|
+
* - `-1`: key does not exist
|
|
106
|
+
* - `>= 0`: length of cleared items in collection
|
|
107
|
+
* */
|
|
48
108
|
clearArray(key) {
|
|
49
109
|
if (typeof key !== "symbol") {
|
|
50
110
|
return -2;
|
|
@@ -57,9 +117,21 @@ export class RepoCommon {
|
|
|
57
117
|
item.splice(0, length);
|
|
58
118
|
return length;
|
|
59
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* List all array keys
|
|
122
|
+
*
|
|
123
|
+
* @return {Array<symbol>}
|
|
124
|
+
* */
|
|
60
125
|
listArrays() {
|
|
61
126
|
return Array.from(this._arrayItems.keys());
|
|
62
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Print all arrays
|
|
130
|
+
*
|
|
131
|
+
* @return {Record} - as {key: length of collection}
|
|
132
|
+
*
|
|
133
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
134
|
+
* */
|
|
63
135
|
printArrays() {
|
|
64
136
|
const result = {};
|
|
65
137
|
let index = 0;
|
|
@@ -76,6 +148,15 @@ export class RepoCommon {
|
|
|
76
148
|
}
|
|
77
149
|
return result;
|
|
78
150
|
}
|
|
151
|
+
// endregion array
|
|
152
|
+
// region list
|
|
153
|
+
/**
|
|
154
|
+
* Create new list
|
|
155
|
+
*
|
|
156
|
+
* @param {string} name - name of collection
|
|
157
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
158
|
+
* @return {List<any>}
|
|
159
|
+
* */
|
|
79
160
|
newList(name, volatile) {
|
|
80
161
|
if (!isText(name)) {
|
|
81
162
|
throw new DeveloperError("Invalid repository list name", testCase(FQN, 141), where);
|
|
@@ -88,6 +169,17 @@ export class RepoCommon {
|
|
|
88
169
|
}
|
|
89
170
|
return item;
|
|
90
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Remove list by given key
|
|
174
|
+
*
|
|
175
|
+
* @param {symbol} key - key of collection
|
|
176
|
+
* @return {number}
|
|
177
|
+
*
|
|
178
|
+
* Return possibilities:
|
|
179
|
+
* - `-2`: key is not valid symbol
|
|
180
|
+
* - `-1`: key does not exist
|
|
181
|
+
* - `>= 0`: length of removed items in collection
|
|
182
|
+
* */
|
|
91
183
|
removeList(key) {
|
|
92
184
|
const cleared = this.clearList(key);
|
|
93
185
|
if (cleared >= 0) {
|
|
@@ -98,6 +190,17 @@ export class RepoCommon {
|
|
|
98
190
|
}
|
|
99
191
|
return cleared;
|
|
100
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Clear list by given key
|
|
195
|
+
*
|
|
196
|
+
* @param {symbol} key - key of collection
|
|
197
|
+
* @return {number}
|
|
198
|
+
*
|
|
199
|
+
* Return possibilities:
|
|
200
|
+
* - `-2`: key is not valid symbol
|
|
201
|
+
* - `-1`: key does not exist
|
|
202
|
+
* - `>= 0`: length of cleared items in collection
|
|
203
|
+
* */
|
|
101
204
|
clearList(key) {
|
|
102
205
|
if (typeof key !== "symbol") {
|
|
103
206
|
return -2;
|
|
@@ -110,9 +213,21 @@ export class RepoCommon {
|
|
|
110
213
|
item.clear();
|
|
111
214
|
return length;
|
|
112
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* List all list keys
|
|
218
|
+
*
|
|
219
|
+
* @return {Array<symbol>}
|
|
220
|
+
* */
|
|
113
221
|
listLists() {
|
|
114
222
|
return Array.from(this._listItems.keys());
|
|
115
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Print all lists
|
|
226
|
+
*
|
|
227
|
+
* @return {Record} - as {key: length of collection}
|
|
228
|
+
*
|
|
229
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
230
|
+
* */
|
|
116
231
|
printLists() {
|
|
117
232
|
const result = {};
|
|
118
233
|
let index = 0;
|
|
@@ -129,6 +244,15 @@ export class RepoCommon {
|
|
|
129
244
|
}
|
|
130
245
|
return result;
|
|
131
246
|
}
|
|
247
|
+
// endregion list
|
|
248
|
+
// region map
|
|
249
|
+
/**
|
|
250
|
+
* Create new map
|
|
251
|
+
*
|
|
252
|
+
* @param {string} name - name of collection
|
|
253
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
254
|
+
* @return {Map<any, any>}
|
|
255
|
+
* */
|
|
132
256
|
newMap(name, volatile) {
|
|
133
257
|
if (!isText(name)) {
|
|
134
258
|
throw new DeveloperError("Invalid repository map name", testCase(FQN, 142), where);
|
|
@@ -141,6 +265,17 @@ export class RepoCommon {
|
|
|
141
265
|
}
|
|
142
266
|
return item;
|
|
143
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Remove map by given key
|
|
270
|
+
*
|
|
271
|
+
* @param {symbol} key - key of collection
|
|
272
|
+
* @return {number}
|
|
273
|
+
*
|
|
274
|
+
* Return possibilities:
|
|
275
|
+
* - `-2`: key is not valid symbol
|
|
276
|
+
* - `-1`: key does not exist
|
|
277
|
+
* - `>= 0`: length of removed items in collection
|
|
278
|
+
* */
|
|
144
279
|
removeMap(key) {
|
|
145
280
|
const cleared = this.clearMap(key);
|
|
146
281
|
if (cleared >= 0) {
|
|
@@ -151,6 +286,17 @@ export class RepoCommon {
|
|
|
151
286
|
}
|
|
152
287
|
return cleared;
|
|
153
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Clear map by given key
|
|
291
|
+
*
|
|
292
|
+
* @param {symbol} key - key of collection
|
|
293
|
+
* @return {number}
|
|
294
|
+
*
|
|
295
|
+
* Return possibilities:
|
|
296
|
+
* - `-2`: key is not valid symbol
|
|
297
|
+
* - `-1`: key does not exist
|
|
298
|
+
* - `>= 0`: length of cleared items in collection
|
|
299
|
+
* */
|
|
154
300
|
clearMap(key) {
|
|
155
301
|
if (typeof key !== "symbol") {
|
|
156
302
|
return -2;
|
|
@@ -163,9 +309,22 @@ export class RepoCommon {
|
|
|
163
309
|
item.clear();
|
|
164
310
|
return length;
|
|
165
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* List all map keys
|
|
314
|
+
*
|
|
315
|
+
* @return {Array<symbol>}
|
|
316
|
+
* */
|
|
166
317
|
listMaps() {
|
|
167
318
|
return Array.from(this._mapItems.keys());
|
|
168
319
|
}
|
|
320
|
+
// noinspection JSUnusedGlobalSymbols
|
|
321
|
+
/**
|
|
322
|
+
* Print all maps
|
|
323
|
+
*
|
|
324
|
+
* @return {Record} - as {key: length of collection}
|
|
325
|
+
*
|
|
326
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
327
|
+
* */
|
|
169
328
|
printMaps() {
|
|
170
329
|
const result = {};
|
|
171
330
|
let index = 0;
|
|
@@ -182,6 +341,15 @@ export class RepoCommon {
|
|
|
182
341
|
}
|
|
183
342
|
return result;
|
|
184
343
|
}
|
|
344
|
+
// endregion map
|
|
345
|
+
// region set
|
|
346
|
+
/**
|
|
347
|
+
* Create new set
|
|
348
|
+
*
|
|
349
|
+
* @param {string} name - name of collection
|
|
350
|
+
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
351
|
+
* @return {Set<any>}
|
|
352
|
+
* */
|
|
185
353
|
newSet(name, volatile) {
|
|
186
354
|
if (!isText(name)) {
|
|
187
355
|
throw new DeveloperError("Invalid repository set name", testCase(FQN, 143), where);
|
|
@@ -194,6 +362,18 @@ export class RepoCommon {
|
|
|
194
362
|
}
|
|
195
363
|
return item;
|
|
196
364
|
}
|
|
365
|
+
// noinspection JSUnusedGlobalSymbols
|
|
366
|
+
/**
|
|
367
|
+
* Remove set by given key
|
|
368
|
+
*
|
|
369
|
+
* @param {symbol} key - key of collection
|
|
370
|
+
* @return {number}
|
|
371
|
+
*
|
|
372
|
+
* Return possibilities:
|
|
373
|
+
* - `-2`: key is not valid symbol
|
|
374
|
+
* - `-1`: key does not exist
|
|
375
|
+
* - `>= 0`: length of removed items in collection
|
|
376
|
+
* */
|
|
197
377
|
removeSet(key) {
|
|
198
378
|
const cleared = this.clearSet(key);
|
|
199
379
|
if (cleared >= 0) {
|
|
@@ -204,6 +384,17 @@ export class RepoCommon {
|
|
|
204
384
|
}
|
|
205
385
|
return cleared;
|
|
206
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Clear set by given key
|
|
389
|
+
*
|
|
390
|
+
* @param {symbol} key - key of collection
|
|
391
|
+
* @return {number}
|
|
392
|
+
*
|
|
393
|
+
* Return possibilities:
|
|
394
|
+
* - `-2`: key is not valid symbol
|
|
395
|
+
* - `-1`: key does not exist
|
|
396
|
+
* - `>= 0`: length of cleared items in collection
|
|
397
|
+
* */
|
|
207
398
|
clearSet(key) {
|
|
208
399
|
if (typeof key !== "symbol") {
|
|
209
400
|
return -2;
|
|
@@ -216,9 +407,23 @@ export class RepoCommon {
|
|
|
216
407
|
item.clear();
|
|
217
408
|
return length;
|
|
218
409
|
}
|
|
410
|
+
// noinspection JSUnusedGlobalSymbols
|
|
411
|
+
/**
|
|
412
|
+
* List all set keys
|
|
413
|
+
*
|
|
414
|
+
* @return {Array<symbol>}
|
|
415
|
+
* */
|
|
219
416
|
listSets() {
|
|
220
417
|
return Array.from(this._setItems.keys());
|
|
221
418
|
}
|
|
419
|
+
// noinspection JSUnusedGlobalSymbols
|
|
420
|
+
/**
|
|
421
|
+
* Print all sets
|
|
422
|
+
*
|
|
423
|
+
* @return {Record} - as {key: length of collection}
|
|
424
|
+
*
|
|
425
|
+
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
426
|
+
* */
|
|
222
427
|
printSets() {
|
|
223
428
|
const result = {};
|
|
224
429
|
let index = 0;
|
|
@@ -235,20 +440,26 @@ export class RepoCommon {
|
|
|
235
440
|
}
|
|
236
441
|
return result;
|
|
237
442
|
}
|
|
443
|
+
// endregion set
|
|
444
|
+
// region secure
|
|
238
445
|
init() {
|
|
239
446
|
const lifecycle = this.leyyo.lifecycleCommon;
|
|
447
|
+
// clear volatile arrays
|
|
240
448
|
lifecycle.addStage("clear", "repo.array", () => {
|
|
241
449
|
Array.from(this._arrayVolatiles.values()).forEach((key) => this._arrayItems.delete(key));
|
|
242
450
|
this._arrayVolatiles.clear();
|
|
243
451
|
});
|
|
452
|
+
// clear volatile lists
|
|
244
453
|
lifecycle.addStage("clear", "repo.list", () => {
|
|
245
454
|
Array.from(this._listVolatiles.values()).forEach((key) => this._listItems.delete(key));
|
|
246
455
|
this._listVolatiles.clear();
|
|
247
456
|
});
|
|
457
|
+
// clear volatile maps
|
|
248
458
|
lifecycle.addStage("clear", "repo.map", () => {
|
|
249
459
|
Array.from(this._mapVolatiles.values()).forEach((key) => this._mapItems.delete(key));
|
|
250
460
|
this._mapVolatiles.clear();
|
|
251
461
|
});
|
|
462
|
+
// clear volatile sets
|
|
252
463
|
lifecycle.addStage("clear", "repo.set", () => {
|
|
253
464
|
Array.from(this._setVolatiles.values()).forEach((key) => this._setItems.delete(key));
|
|
254
465
|
this._setVolatiles.clear();
|
package/dist/const/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export declare const VAL_FQN_ANONYMOUS = "#Fqn";
|
|
2
|
+
/**
|
|
3
|
+
* Normal empty values
|
|
4
|
+
* */
|
|
2
5
|
export declare const EMPTY_VALUES: any[];
|
|
6
|
+
/**
|
|
7
|
+
* Empty values with empty string
|
|
8
|
+
* */
|
|
3
9
|
export declare const EMPTY_VALUES_STR: Array<unknown>;
|
|
4
10
|
export declare const VAL_NAME_ANONYMOUS: string;
|
|
5
11
|
export declare const VAL_ERROR_UNKNOWN_NAME: string;
|
package/dist/const/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export const VAL_FQN_ANONYMOUS = "#Fqn";
|
|
2
|
+
/**
|
|
3
|
+
* Normal empty values
|
|
4
|
+
* */
|
|
2
5
|
export const EMPTY_VALUES = [null, undefined];
|
|
6
|
+
// noinspection JSUnusedGlobalSymbols
|
|
7
|
+
/**
|
|
8
|
+
* Empty values with empty string
|
|
9
|
+
* */
|
|
3
10
|
export const EMPTY_VALUES_STR = [null, undefined, ""];
|
|
4
11
|
export const VAL_NAME_ANONYMOUS = "~";
|
|
5
12
|
export const VAL_ERROR_UNKNOWN_NAME = "UnknownError";
|
package/dist/enum/log-level.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
2
|
import { Opt } from "../function/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Caused error
|
|
5
|
+
* */
|
|
3
6
|
export declare class CausedError extends LeyyoError {
|
|
7
|
+
/**
|
|
8
|
+
* Cast a native error to caused error
|
|
9
|
+
*
|
|
10
|
+
* @param {Error} e - native error instance
|
|
11
|
+
* @param {Opt?} params - params for error
|
|
12
|
+
* @return {CausedError} - new caused error instance
|
|
13
|
+
* */
|
|
4
14
|
static of(e: Error, params?: Opt): CausedError;
|
|
5
15
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Caused error
|
|
4
|
+
* */
|
|
2
5
|
export class CausedError extends LeyyoError {
|
|
6
|
+
/**
|
|
7
|
+
* Cast a native error to caused error
|
|
8
|
+
*
|
|
9
|
+
* @param {Error} e - native error instance
|
|
10
|
+
* @param {Opt?} params - params for error
|
|
11
|
+
* @return {CausedError} - new caused error instance
|
|
12
|
+
* */
|
|
3
13
|
static of(e, params) {
|
|
4
14
|
const err = new CausedError(e.message, params);
|
|
5
15
|
err.causedBy = e;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { KEY_DEVELOPER_CASE, KEY_DEVELOPER_WHERE, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
2
2
|
import { LeyyoLike } from "../base/index.js";
|
|
3
3
|
import { DeveloperErrorLike, ErrorStackLine } from "./index.types.js";
|
|
4
|
+
/** Developer error */
|
|
4
5
|
export declare class DeveloperError extends Error implements DeveloperErrorLike {
|
|
5
6
|
protected [KEY_DEVELOPER_CASE]: string;
|
|
6
7
|
protected [KEY_DEVELOPER_WHERE]: string;
|
|
8
|
+
/** @inheritDoc */
|
|
7
9
|
stackTrace?: Array<ErrorStackLine>;
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} message - error message
|
|
12
|
+
* @param {string} issue - test case
|
|
13
|
+
* @param {string} where - where
|
|
14
|
+
* */
|
|
8
15
|
constructor(message: string, issue?: string, where?: string);
|
|
9
16
|
static [KEY_LEYYO_SECURE](leyyo: LeyyoLike): void;
|
|
17
|
+
/** @inheritDoc */
|
|
10
18
|
log(err?: Error): void;
|
|
11
19
|
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { KEY_DEVELOPER_CASE, KEY_DEVELOPER_WHERE, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
2
|
+
// region properties
|
|
2
3
|
let _leyyo;
|
|
4
|
+
// endregion properties
|
|
5
|
+
/** Developer error */
|
|
3
6
|
export class DeveloperError extends Error {
|
|
4
7
|
[KEY_DEVELOPER_CASE];
|
|
5
8
|
[KEY_DEVELOPER_WHERE];
|
|
9
|
+
/** @inheritDoc */
|
|
6
10
|
stackTrace;
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} message - error message
|
|
13
|
+
* @param {string} issue - test case
|
|
14
|
+
* @param {string} where - where
|
|
15
|
+
* */
|
|
7
16
|
constructor(message, issue, where) {
|
|
8
17
|
message = message ?? "Developer error";
|
|
9
18
|
super(message);
|
|
@@ -20,6 +29,7 @@ export class DeveloperError extends Error {
|
|
|
20
29
|
_leyyo = leyyo;
|
|
21
30
|
}
|
|
22
31
|
}
|
|
32
|
+
/** @inheritDoc */
|
|
23
33
|
log(err) {
|
|
24
34
|
if (err instanceof Error) {
|
|
25
35
|
this["causedBy"] = err;
|