@avstantso/concepts 1.1.0 → 1.2.1
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/CHANGELOG.md +7 -0
- package/dist/_global/async-tasks.d.ts +134 -0
- package/dist/_global/classic-enum.d.ts +29 -0
- package/dist/_global/compare/_register.d.ts +32 -0
- package/dist/_global/compare/combination.d.ts +41 -0
- package/dist/_global/compare/compare.d.ts +39 -0
- package/dist/_global/compare/index.d.ts +4 -0
- package/dist/_global/compare/structures.d.ts +10 -0
- package/dist/_global/conveyor.d.ts +18 -0
- package/dist/_global/equality/_register.d.ts +35 -0
- package/dist/_global/equality/equality.d.ts +32 -0
- package/dist/_global/equality/index.d.ts +2 -0
- package/dist/_global/extend/_register.d.ts +76 -0
- package/dist/_global/extend/index.d.ts +1 -0
- package/dist/_global/index.d.ts +15 -0
- package/dist/_global/mapping/_register.d.ts +59 -0
- package/dist/_global/mapping/index.d.ts +2 -0
- package/dist/_global/mapping/mapping.d.ts +138 -0
- package/dist/_global/mock.d.ts +11 -0
- package/dist/_global/override.d.ts +50 -0
- package/dist/_global/perform/_register.d.ts +107 -0
- package/dist/_global/perform/index.d.ts +1 -0
- package/dist/_global/provider/_register.d.ts +16 -0
- package/dist/_global/provider/combination.d.ts +96 -0
- package/dist/_global/provider/compare.d.ts +47 -0
- package/dist/_global/provider/extract.d.ts +36 -0
- package/dist/_global/provider/force.d.ts +35 -0
- package/dist/_global/provider/index.d.ts +10 -0
- package/dist/_global/provider/is.d.ts +38 -0
- package/dist/_global/provider/provider.d.ts +85 -0
- package/dist/_global/provider/strict.d.ts +29 -0
- package/dist/_global/provider/union.d.ts +29 -0
- package/dist/_global/provider/value.d.ts +26 -0
- package/dist/_global/stub.d.ts +40 -0
- package/dist/_global/switch/_register.d.ts +45 -0
- package/dist/_global/switch/index.d.ts +2 -0
- package/dist/_global/switch/switch.d.ts +13 -0
- package/dist/_global/transition.d.ts +62 -0
- package/dist/_global/value-wrap.d.ts +12 -0
- package/dist/_std-ext/abort-controller.d.ts +7 -0
- package/dist/_std-ext/index.d.ts +1 -0
- package/dist/export.d.ts +16 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +699 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
package/dist/index.js
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@avstantso/errors');
|
|
4
|
+
require('@avstantso/js');
|
|
5
|
+
|
|
6
|
+
var AVStantso$e;
|
|
7
|
+
(function (AVStantso) {
|
|
8
|
+
AVStantso.Perform = avstantso._reg.Perform(({ JS }) => {
|
|
9
|
+
function isOptions(candidate) {
|
|
10
|
+
return null !== candidate
|
|
11
|
+
&& JS.is.object(candidate)
|
|
12
|
+
&& ('afterCallback' in candidate || 'params' in candidate);
|
|
13
|
+
}
|
|
14
|
+
function parseSimpleOptions(inParams) {
|
|
15
|
+
return (isOptions(inParams[0])
|
|
16
|
+
? { params: [], ...inParams[0] }
|
|
17
|
+
: { params: inParams });
|
|
18
|
+
}
|
|
19
|
+
function perform(p, ...inParams) {
|
|
20
|
+
const { afterCallback, params } = parseSimpleOptions(inParams);
|
|
21
|
+
const r = JS.is.function(p) ? p(...params) : p;
|
|
22
|
+
if (afterCallback)
|
|
23
|
+
afterCallback(r);
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
26
|
+
async function performPromise(p, ...inParams) {
|
|
27
|
+
const pR = await Promise.resolve(p);
|
|
28
|
+
const pP = perform(pR, ...inParams);
|
|
29
|
+
return Promise.resolve(pP);
|
|
30
|
+
}
|
|
31
|
+
function parseListOptions(inParams) {
|
|
32
|
+
const options = isOptions(inParams[0])
|
|
33
|
+
? inParams.shift()
|
|
34
|
+
: undefined;
|
|
35
|
+
const params = Array.isArray(inParams[0])
|
|
36
|
+
? inParams[0]
|
|
37
|
+
: inParams;
|
|
38
|
+
return [options, ...params];
|
|
39
|
+
}
|
|
40
|
+
function performList(...inParams) {
|
|
41
|
+
const [options, ...items] = parseListOptions(inParams);
|
|
42
|
+
const r = [];
|
|
43
|
+
for (let i = 0; i < items.length; i++) {
|
|
44
|
+
const item = perform(items[i], options);
|
|
45
|
+
if (Array.isArray(item))
|
|
46
|
+
r.push(...item);
|
|
47
|
+
else
|
|
48
|
+
r.push(item);
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
}
|
|
52
|
+
async function performPromiseList(...inParams) {
|
|
53
|
+
const [options, ...items] = parseListOptions(inParams);
|
|
54
|
+
const r = [];
|
|
55
|
+
for (let i = 0; i < items.length; i++) {
|
|
56
|
+
const item = await performPromise(items[i], options);
|
|
57
|
+
if (Array.isArray(item))
|
|
58
|
+
r.push(...item);
|
|
59
|
+
else
|
|
60
|
+
r.push(item);
|
|
61
|
+
}
|
|
62
|
+
return r;
|
|
63
|
+
}
|
|
64
|
+
const Perform = Object.assign(perform, {
|
|
65
|
+
Options: { is: isOptions },
|
|
66
|
+
List: performList,
|
|
67
|
+
Promise: Object.assign(performPromise, { List: performPromiseList })
|
|
68
|
+
});
|
|
69
|
+
return Perform;
|
|
70
|
+
});
|
|
71
|
+
})(AVStantso$e || (AVStantso$e = {}));
|
|
72
|
+
|
|
73
|
+
var AVStantso$d;
|
|
74
|
+
(function (AVStantso) {
|
|
75
|
+
AVStantso.Compare = avstantso._reg.Compare(({ Perform }) => {
|
|
76
|
+
function Extend(compareFunc) {
|
|
77
|
+
return Object.defineProperties(compareFunc, {
|
|
78
|
+
as: { value: () => compareFunc },
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
desc: { value: (a, b) => compareFunc(b, a) }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function ToNulls(allowNaN, nullsFirst) {
|
|
84
|
+
return (x) => undefined === x
|
|
85
|
+
? -3
|
|
86
|
+
: null === x
|
|
87
|
+
? -2
|
|
88
|
+
: allowNaN && isNaN(x)
|
|
89
|
+
? -1
|
|
90
|
+
: nullsFirst
|
|
91
|
+
? 0
|
|
92
|
+
: -4;
|
|
93
|
+
}
|
|
94
|
+
function Select(...comparisons) {
|
|
95
|
+
for (const c of comparisons) {
|
|
96
|
+
const r = Perform(c);
|
|
97
|
+
if (r !== 0)
|
|
98
|
+
return r;
|
|
99
|
+
}
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
return { Extend, ToNulls, Select };
|
|
103
|
+
});
|
|
104
|
+
})(AVStantso$d || (AVStantso$d = {}));
|
|
105
|
+
|
|
106
|
+
(function (AVStantso) {
|
|
107
|
+
avstantso._reg.Compare.Combine(({ JS, Compare: { Extend } }) => {
|
|
108
|
+
function Combine(...compares) {
|
|
109
|
+
function combined(a, b) {
|
|
110
|
+
for (const cRaw of compares) {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
const c = JS.is.function(cRaw) ? cRaw : cRaw.Compare;
|
|
113
|
+
const r = c(a, b);
|
|
114
|
+
if (0 !== r)
|
|
115
|
+
return r;
|
|
116
|
+
}
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
return Extend(combined);
|
|
120
|
+
}
|
|
121
|
+
return Combine;
|
|
122
|
+
});
|
|
123
|
+
})();
|
|
124
|
+
|
|
125
|
+
(function (AVStantso) {
|
|
126
|
+
avstantso._reg.Compare.Structures(({ AtomicObjects: SimpleObjects, JS, Compare: { ToNulls, Extend } }) => {
|
|
127
|
+
const fo = [JS.function, JS.object];
|
|
128
|
+
const st = [JS.string, JS.symbol];
|
|
129
|
+
const nm = [JS.number, JS.bigint];
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
function compareStructures(a, b) {
|
|
132
|
+
const t = { a: typeof a, b: typeof b };
|
|
133
|
+
let r = ToNulls(nm.includes(t.a))(a) - ToNulls(nm.includes(t.b))(b);
|
|
134
|
+
if (r !== 0)
|
|
135
|
+
return r;
|
|
136
|
+
function cmbBools({ a, b }) {
|
|
137
|
+
return (a ? 1 : 0) - (b ? 1 : 0);
|
|
138
|
+
}
|
|
139
|
+
const io = {
|
|
140
|
+
a: fo.includes(t.a),
|
|
141
|
+
b: fo.includes(t.b)
|
|
142
|
+
};
|
|
143
|
+
if (io.a !== io.b)
|
|
144
|
+
return cmbBools(io);
|
|
145
|
+
// Object/Function
|
|
146
|
+
if (io.a) {
|
|
147
|
+
const ia = { a: Array.isArray(a), b: Array.isArray(a) };
|
|
148
|
+
if (ia.a !== ia.b)
|
|
149
|
+
return cmbBools(ia);
|
|
150
|
+
// Array
|
|
151
|
+
if (ia.a) {
|
|
152
|
+
for (let la = a.length, lb = b.length, l = Math.max(la, lb), i = 0; i < l; i++) {
|
|
153
|
+
if (i >= la)
|
|
154
|
+
return -1;
|
|
155
|
+
if (i >= lb)
|
|
156
|
+
return 1;
|
|
157
|
+
r = compareStructures(a[i], b[i]);
|
|
158
|
+
if (r !== 0)
|
|
159
|
+
return r;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// not Array
|
|
163
|
+
else {
|
|
164
|
+
const isSmp = { a: SimpleObjects.is(a), b: SimpleObjects.is(b) };
|
|
165
|
+
if (isSmp.a !== isSmp.b)
|
|
166
|
+
return cmbBools(isSmp);
|
|
167
|
+
if (isSmp.a)
|
|
168
|
+
return +a - +b;
|
|
169
|
+
for (let aa = Object.entries(a), ab = Object.entries(b), la = aa.length, lb = ab.length, l = Math.max(la, lb), i = 0; i < l; i++) {
|
|
170
|
+
if (i >= la)
|
|
171
|
+
return -1;
|
|
172
|
+
if (i >= lb)
|
|
173
|
+
return 1;
|
|
174
|
+
const [ka, va] = aa[i];
|
|
175
|
+
const [kb, vb] = ab[i];
|
|
176
|
+
r = compareStructures(ka, kb);
|
|
177
|
+
if (r !== 0)
|
|
178
|
+
return r;
|
|
179
|
+
r = compareStructures(va, vb);
|
|
180
|
+
if (r !== 0)
|
|
181
|
+
return r;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
// Simple type
|
|
187
|
+
else {
|
|
188
|
+
if (st.includes(t.a) && st.includes(t.b))
|
|
189
|
+
return String(a).localeCompare(String(b));
|
|
190
|
+
if (nm.includes(t.a) && nm.includes(t.b))
|
|
191
|
+
return +a - +b;
|
|
192
|
+
if (t.a !== t.b)
|
|
193
|
+
return t.a.localeCompare(t.b);
|
|
194
|
+
return +a - +b;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return Extend(compareStructures);
|
|
198
|
+
});
|
|
199
|
+
})();
|
|
200
|
+
|
|
201
|
+
var AVStantso$c;
|
|
202
|
+
(function (AVStantso) {
|
|
203
|
+
AVStantso.Provider = avstantso._reg.Provider({});
|
|
204
|
+
})(AVStantso$c || (AVStantso$c = {}));
|
|
205
|
+
|
|
206
|
+
(function (AVStantso) {
|
|
207
|
+
avstantso._reg.Provider.Is(({ TS, JS }) => {
|
|
208
|
+
function ProviderIs(...params) {
|
|
209
|
+
const [key, type] = TS.Type.KLD.Parse(params);
|
|
210
|
+
function is(candidate) {
|
|
211
|
+
if (null === candidate || !JS.is.object(candidate) || !(key in candidate))
|
|
212
|
+
return false;
|
|
213
|
+
const value = candidate[key];
|
|
214
|
+
return !type || TS.Literal.IsValue(type, value);
|
|
215
|
+
}
|
|
216
|
+
return is;
|
|
217
|
+
}
|
|
218
|
+
return ProviderIs;
|
|
219
|
+
});
|
|
220
|
+
})();
|
|
221
|
+
|
|
222
|
+
(function (AVStantso) {
|
|
223
|
+
avstantso._reg.Provider.Extract(({ TS, JS }) => {
|
|
224
|
+
function ProviderExtract(...params) {
|
|
225
|
+
const [key, type] = TS.Type.KLD.Parse(params);
|
|
226
|
+
function extract(union) {
|
|
227
|
+
return undefined === union || null === union || TS.Literal.IsValue(type, union)
|
|
228
|
+
? union
|
|
229
|
+
: JS.is.object(union)
|
|
230
|
+
? union[key]
|
|
231
|
+
: undefined;
|
|
232
|
+
}
|
|
233
|
+
return extract;
|
|
234
|
+
}
|
|
235
|
+
return ProviderExtract;
|
|
236
|
+
});
|
|
237
|
+
})();
|
|
238
|
+
|
|
239
|
+
(function (AVStantso) {
|
|
240
|
+
avstantso._reg.Provider.Compare(({ TS, Compare: { Extend, ToNulls }, Provider: { Extract } }) => {
|
|
241
|
+
function Compare(...params) {
|
|
242
|
+
const L = TS.Literal;
|
|
243
|
+
const [key, type] = TS.Type.KLD.Parse(params);
|
|
244
|
+
const { extract } = (params[Array.isArray(params[0]) ? 1 : 2] || {
|
|
245
|
+
extract: Extract(key, type)
|
|
246
|
+
});
|
|
247
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
248
|
+
function compare(a, b) {
|
|
249
|
+
const ea = extract(a);
|
|
250
|
+
const eb = extract(b);
|
|
251
|
+
const toNulls = ToNulls(type === L.number);
|
|
252
|
+
{
|
|
253
|
+
const nr = toNulls(ea) - toNulls(eb);
|
|
254
|
+
if (nr)
|
|
255
|
+
return nr;
|
|
256
|
+
}
|
|
257
|
+
if (L.Buffer === type && a instanceof Buffer && b instanceof Buffer)
|
|
258
|
+
return a.toString('hex').localeCompare(b.toString('hex'));
|
|
259
|
+
if (L.string !== type && L.symbol !== type)
|
|
260
|
+
return +ea - +eb;
|
|
261
|
+
const sa = String(ea || '');
|
|
262
|
+
const sb = String(eb || '');
|
|
263
|
+
return sa.localeCompare(sb);
|
|
264
|
+
}
|
|
265
|
+
return Extend(compare);
|
|
266
|
+
}
|
|
267
|
+
return Compare;
|
|
268
|
+
});
|
|
269
|
+
})();
|
|
270
|
+
|
|
271
|
+
(function (AVStantso) {
|
|
272
|
+
avstantso._reg.Provider.Force(({ Generic }) => (function Force() {
|
|
273
|
+
return Generic.Cast;
|
|
274
|
+
}));
|
|
275
|
+
})();
|
|
276
|
+
|
|
277
|
+
var AVStantso$b;
|
|
278
|
+
(function (AVStantso) {
|
|
279
|
+
AVStantso.Equality = avstantso._reg.Equality(() => {
|
|
280
|
+
const PredicateFactory = (equality) => (a, notEquals) => (b) => {
|
|
281
|
+
const r = equality(a, b);
|
|
282
|
+
return notEquals ? !r : !!r;
|
|
283
|
+
};
|
|
284
|
+
const From = (compare) => {
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
+
function equality(a, b) {
|
|
287
|
+
return !compare(a, b);
|
|
288
|
+
}
|
|
289
|
+
equality.as = () => equality;
|
|
290
|
+
return equality;
|
|
291
|
+
};
|
|
292
|
+
return { Predicate: { Factory: PredicateFactory }, From };
|
|
293
|
+
});
|
|
294
|
+
})(AVStantso$b || (AVStantso$b = {}));
|
|
295
|
+
|
|
296
|
+
var AVStantso$a;
|
|
297
|
+
(function (AVStantso) {
|
|
298
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-explicit-any */
|
|
299
|
+
/**
|
|
300
|
+
* @summary Cast object or function for add extended fields
|
|
301
|
+
* @param from as TFrom
|
|
302
|
+
* @returns from as TTo
|
|
303
|
+
*/
|
|
304
|
+
AVStantso.Extend = avstantso._reg.Extend(({ JS }) => {
|
|
305
|
+
function extendByRecord(keys, getValue) {
|
|
306
|
+
function MKM(transformKey) {
|
|
307
|
+
function MK(isStatic) {
|
|
308
|
+
const f0 = (original, extender) => {
|
|
309
|
+
(JS.is.function(keys) ? keys() : keys).forEach((key) => {
|
|
310
|
+
if (transformKey && !JS.is.string(key))
|
|
311
|
+
throw new AVStantso_SystemError(`Extend.ByRecord.Capitalized/Uncapitalized not support "${typeof key}" keys ("${String(key)}")`);
|
|
312
|
+
const customKey = (transformKey ? transformKey(key) : key);
|
|
313
|
+
function _extender() {
|
|
314
|
+
return extender.call(this, getValue ? getValue(key) : key, original, key);
|
|
315
|
+
}
|
|
316
|
+
if (isStatic)
|
|
317
|
+
Object.assign(original, { [customKey]: _extender() });
|
|
318
|
+
else
|
|
319
|
+
Object.defineProperty(original, customKey, {
|
|
320
|
+
get: _extender
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
return original;
|
|
324
|
+
};
|
|
325
|
+
return f0;
|
|
326
|
+
}
|
|
327
|
+
const f1 = MK();
|
|
328
|
+
f1.static = MK(true);
|
|
329
|
+
return f1;
|
|
330
|
+
}
|
|
331
|
+
const f2 = MKM();
|
|
332
|
+
f2.Capitalized = MKM((key) => String(key).toCapitalized());
|
|
333
|
+
f2.Uncapitalized = MKM((key) => String(key).toUncapitalized());
|
|
334
|
+
return f2;
|
|
335
|
+
}
|
|
336
|
+
function extendArbitrary(original, extention) {
|
|
337
|
+
const e = JS.is.function(extention) ? extention() : extention;
|
|
338
|
+
return Object.assign(original, e);
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
ByRecord: extendByRecord,
|
|
342
|
+
Arbitrary: extendArbitrary
|
|
343
|
+
};
|
|
344
|
+
});
|
|
345
|
+
})(AVStantso$a || (AVStantso$a = {}));
|
|
346
|
+
|
|
347
|
+
var AVStantso$9;
|
|
348
|
+
(function (AVStantso) {
|
|
349
|
+
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
350
|
+
AVStantso.Switch = avstantso._reg.Switch(() => {
|
|
351
|
+
return (getKey) => {
|
|
352
|
+
function _switch(value, cases) {
|
|
353
|
+
/* eslint-disable no-fallthrough */
|
|
354
|
+
switch (value) {
|
|
355
|
+
case undefined:
|
|
356
|
+
if ('undefined' in cases)
|
|
357
|
+
return cases.undefined;
|
|
358
|
+
case null:
|
|
359
|
+
if ('null' in cases)
|
|
360
|
+
return cases.null;
|
|
361
|
+
default: {
|
|
362
|
+
const key = String(getKey(value));
|
|
363
|
+
return key in cases ? cases[key] : cases.default;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return Object.assign(_switch, {
|
|
368
|
+
reversed(cases, value) {
|
|
369
|
+
return _switch(value, cases);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
})(AVStantso$9 || (AVStantso$9 = {}));
|
|
375
|
+
|
|
376
|
+
var AVStantso$8;
|
|
377
|
+
(function (AVStantso) {
|
|
378
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-explicit-any */
|
|
379
|
+
AVStantso.Stub = avstantso._reg.Stub(({ X }) => {
|
|
380
|
+
function customStub(stub) {
|
|
381
|
+
return ((...params) => 1 === params.length ? stub(params[0]) : params.map(stub));
|
|
382
|
+
}
|
|
383
|
+
return Object.assign(customStub((func) => func || X), {
|
|
384
|
+
Custom: customStub
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
})(AVStantso$8 || (AVStantso$8 = {}));
|
|
388
|
+
|
|
389
|
+
var AVStantso$7;
|
|
390
|
+
(function (AVStantso) {
|
|
391
|
+
AVStantso.Mock = avstantso._reg.Mock(({ JS, X }) => {
|
|
392
|
+
function Mock(source, doNotUseMocking) {
|
|
393
|
+
return new Proxy(source, {
|
|
394
|
+
get: (target, p) => {
|
|
395
|
+
const src = Reflect.get(target, p);
|
|
396
|
+
return doNotUseMocking
|
|
397
|
+
? src
|
|
398
|
+
: JS.is.function(src)
|
|
399
|
+
? X
|
|
400
|
+
: undefined;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
return Mock;
|
|
405
|
+
});
|
|
406
|
+
})(AVStantso$7 || (AVStantso$7 = {}));
|
|
407
|
+
|
|
408
|
+
var AVStantso$6;
|
|
409
|
+
(function (AVStantso) {
|
|
410
|
+
AVStantso.Mapping = avstantso._reg.Mapping(({ TS, JS }) => ((...params) => {
|
|
411
|
+
const subSwitch = (i) => ({
|
|
412
|
+
object: () => ({ map: params[i] }),
|
|
413
|
+
function: () => ({ keyFromValue: params[i], map: params[i + 1] }),
|
|
414
|
+
default: () => {
|
|
415
|
+
throw new AVStantso_InvalidArgumentTypeError('AVStantso', 'Mapping', [!i && JS.string, JS.object, JS.function].pack().join('|'), { [`param${i}`]: params[i] });
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
419
|
+
const { field, keyFromValue, map } = JS.switch(params[0], {
|
|
420
|
+
...subSwitch(0),
|
|
421
|
+
string: () => ({
|
|
422
|
+
field: params[0],
|
|
423
|
+
...JS.switch(params[1], subSwitch(1))
|
|
424
|
+
}),
|
|
425
|
+
undefined: () => JS.switch(params[1], subSwitch(1))
|
|
426
|
+
});
|
|
427
|
+
const kfv = keyFromValue || TS.Structure.keyByValue.bind(null, field, map);
|
|
428
|
+
return (template) => (value) => template[kfv(value)];
|
|
429
|
+
}));
|
|
430
|
+
})(AVStantso$6 || (AVStantso$6 = {}));
|
|
431
|
+
|
|
432
|
+
var AVStantso$5;
|
|
433
|
+
(function (AVStantso) {
|
|
434
|
+
AVStantso.Conveyor = avstantso._reg.Conveyor(({ JS }) => function Conveyor(original, ...transformers) {
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
436
|
+
let r = original;
|
|
437
|
+
if (r && JS.is.object(r))
|
|
438
|
+
r = Array.isArray(r) ? [...r] : { ...r };
|
|
439
|
+
for (const t of transformers)
|
|
440
|
+
if (t)
|
|
441
|
+
r = t.call(r, r);
|
|
442
|
+
return r;
|
|
443
|
+
});
|
|
444
|
+
})(AVStantso$5 || (AVStantso$5 = {}));
|
|
445
|
+
|
|
446
|
+
var AVStantso$4;
|
|
447
|
+
(function (AVStantso) {
|
|
448
|
+
/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-explicit-any */
|
|
449
|
+
AVStantso.Override = avstantso._reg.Override(({ JS, Perform }) => {
|
|
450
|
+
function isContext(candidate) {
|
|
451
|
+
return (null !== candidate && JS.is.object(candidate) && 'original' in candidate);
|
|
452
|
+
}
|
|
453
|
+
function Calculator(context) {
|
|
454
|
+
const c = isContext(context) ? context : { original: context };
|
|
455
|
+
return function override(override) {
|
|
456
|
+
const r = undefined === override ? c.original : Perform(override, c);
|
|
457
|
+
return r;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
isContext,
|
|
462
|
+
Calculator
|
|
463
|
+
};
|
|
464
|
+
});
|
|
465
|
+
})(AVStantso$4 || (AVStantso$4 = {}));
|
|
466
|
+
|
|
467
|
+
var AVStantso$3;
|
|
468
|
+
(function (AVStantso) {
|
|
469
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-function-type */
|
|
470
|
+
AVStantso.Transition = avstantso._reg.Transition(({ JS, Perform }) => {
|
|
471
|
+
function Transition(parent, ...params) {
|
|
472
|
+
const isProps = JS.is.object(params[0]);
|
|
473
|
+
const state = isProps ? params[0].state : params[0];
|
|
474
|
+
const begin = isProps ? params[0].begin : params[params.length <= 2 ? undefined : 1];
|
|
475
|
+
const end = isProps ? params[0].end : params[params.length <= 2 ? 1 : 2];
|
|
476
|
+
const hasBegin = isProps ? 'begin' in params[0] : params.length > 2;
|
|
477
|
+
function transition(action) {
|
|
478
|
+
return Promise.resolve()
|
|
479
|
+
.then(() => hasBegin && state(begin))
|
|
480
|
+
.then(() => Perform.Promise(action))
|
|
481
|
+
.finally(() => state(end));
|
|
482
|
+
}
|
|
483
|
+
const curTransition = parent
|
|
484
|
+
? function transitionNested(action) {
|
|
485
|
+
return parent(() => transition(action));
|
|
486
|
+
}
|
|
487
|
+
: transition;
|
|
488
|
+
function Nest(...params) {
|
|
489
|
+
return Transition(curTransition, ...params);
|
|
490
|
+
}
|
|
491
|
+
return Object.assign(curTransition, { Nest });
|
|
492
|
+
}
|
|
493
|
+
return Transition.bind(null, null);
|
|
494
|
+
});
|
|
495
|
+
})(AVStantso$3 || (AVStantso$3 = {}));
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @summary Object wrap around value
|
|
499
|
+
*/
|
|
500
|
+
let AVStantso_ValueWrap$1 = class AVStantso_ValueWrap {
|
|
501
|
+
#value;
|
|
502
|
+
constructor(value) {
|
|
503
|
+
this.#value = value;
|
|
504
|
+
}
|
|
505
|
+
static Clone(source) {
|
|
506
|
+
return Object.assign(new this(source.value), source);
|
|
507
|
+
}
|
|
508
|
+
toString() {
|
|
509
|
+
return this.#value.toString();
|
|
510
|
+
}
|
|
511
|
+
valueOf() {
|
|
512
|
+
return this.#value;
|
|
513
|
+
}
|
|
514
|
+
get value() {
|
|
515
|
+
return this.#value;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
if (!('AVStantso_ValueWrap' in globalThis))
|
|
519
|
+
Object.defineProperties(globalThis, {
|
|
520
|
+
AVStantso_ValueWrap: {
|
|
521
|
+
value: AVStantso_ValueWrap$1,
|
|
522
|
+
writable: false,
|
|
523
|
+
configurable: false
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
avstantso.AtomicObjects.register(AVStantso_ValueWrap$1, {
|
|
527
|
+
empty: () => new AVStantso_ValueWrap$1(null),
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
529
|
+
clone: (instance) => instance.constructor.Clone(instance)
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
var AVStantso$2;
|
|
533
|
+
(function (AVStantso) {
|
|
534
|
+
AVStantso.AsyncTasksManager = avstantso._reg.AsyncTasksManager(({ symbolFreeze, JS }) => {
|
|
535
|
+
const symbolATM = Symbol('AsyncTasksManager');
|
|
536
|
+
function isAsyncTasksManager(candidate) {
|
|
537
|
+
return candidate && JS.is.structure(candidate) && (symbolATM in candidate);
|
|
538
|
+
}
|
|
539
|
+
const onCreateExtenders = [];
|
|
540
|
+
function AsyncTasksManagerCreate() {
|
|
541
|
+
const intervals = new Map();
|
|
542
|
+
const timeouts = new Map();
|
|
543
|
+
const tasks = new Set();
|
|
544
|
+
const MAPS = [
|
|
545
|
+
{ intervals, clearInterval, setInterval },
|
|
546
|
+
{ timeouts, clearTimeout, setTimeout }
|
|
547
|
+
];
|
|
548
|
+
const errors = [];
|
|
549
|
+
let isFinalizig = false;
|
|
550
|
+
function throwIfFinal() {
|
|
551
|
+
if (isFinalizig)
|
|
552
|
+
throw new AVStantso_InvalidStateError('AsyncTasksManager', 'finalizig', "Can't interact with %C on %S");
|
|
553
|
+
}
|
|
554
|
+
async function final(options) {
|
|
555
|
+
const { quiet } = options || {};
|
|
556
|
+
isFinalizig = true;
|
|
557
|
+
const promises = [...tasks];
|
|
558
|
+
for (const mapInfo of MAPS) {
|
|
559
|
+
const [map, clear] = Object.values(mapInfo);
|
|
560
|
+
for (const [t, [c, { callOnFinal } = {}]] of map) {
|
|
561
|
+
if (callOnFinal)
|
|
562
|
+
promises.push(Promise.resolve(0)
|
|
563
|
+
.then(() => c(true))
|
|
564
|
+
.catch((e) => errors.push(e)));
|
|
565
|
+
clear(t);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
await Promise.all(promises);
|
|
569
|
+
if (!quiet)
|
|
570
|
+
for (const e of errors)
|
|
571
|
+
console.error(e);
|
|
572
|
+
}
|
|
573
|
+
function regTask(task) {
|
|
574
|
+
throwIfFinal();
|
|
575
|
+
const p = task
|
|
576
|
+
.catch((e) => {
|
|
577
|
+
if (isFinalizig)
|
|
578
|
+
errors.push(e);
|
|
579
|
+
else
|
|
580
|
+
throw e;
|
|
581
|
+
})
|
|
582
|
+
.finally(() => tasks.delete(p));
|
|
583
|
+
tasks.add(p);
|
|
584
|
+
return p;
|
|
585
|
+
}
|
|
586
|
+
const instance = {
|
|
587
|
+
final,
|
|
588
|
+
regTask,
|
|
589
|
+
get errors() {
|
|
590
|
+
return isFinalizig ? errors : undefined;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
for (const MAP of MAPS) {
|
|
594
|
+
const [[, map], [kClear, vClear], [kSet, vSet]] = Object.entries(MAP);
|
|
595
|
+
Object.assign(instance, {
|
|
596
|
+
[kSet](callback, delay, options) {
|
|
597
|
+
throwIfFinal();
|
|
598
|
+
const t = vSet(callback, delay);
|
|
599
|
+
map.set(t, [callback, options]);
|
|
600
|
+
return t;
|
|
601
|
+
},
|
|
602
|
+
[kClear](timeout) {
|
|
603
|
+
vClear(timeout);
|
|
604
|
+
map.delete(timeout);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
for (const cb of onCreateExtenders)
|
|
609
|
+
cb(instance);
|
|
610
|
+
return instance;
|
|
611
|
+
}
|
|
612
|
+
function AsyncTasksManagerFactory(target) {
|
|
613
|
+
let instance;
|
|
614
|
+
return new Proxy(target, {
|
|
615
|
+
has(target, p) {
|
|
616
|
+
return symbolATM === p ? true : Reflect.has(target, p);
|
|
617
|
+
},
|
|
618
|
+
get(target, p) {
|
|
619
|
+
const r = Reflect.get(target, p);
|
|
620
|
+
if (undefined !== r)
|
|
621
|
+
return r;
|
|
622
|
+
if (!instance)
|
|
623
|
+
instance = AsyncTasksManagerCreate();
|
|
624
|
+
return Reflect.get(instance, p);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
const globalATM = ({
|
|
629
|
+
_RegOnCreate(extenderCallback) {
|
|
630
|
+
onCreateExtenders.push(extenderCallback);
|
|
631
|
+
},
|
|
632
|
+
Factory: AsyncTasksManagerFactory.bind(null, {}),
|
|
633
|
+
is: isAsyncTasksManager,
|
|
634
|
+
[symbolFreeze]() {
|
|
635
|
+
delete this._RegOnCreate;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
return AsyncTasksManagerFactory(globalATM);
|
|
639
|
+
});
|
|
640
|
+
})(AVStantso$2 || (AVStantso$2 = {}));
|
|
641
|
+
|
|
642
|
+
var AVStantso$1;
|
|
643
|
+
(function (AVStantso) {
|
|
644
|
+
AVStantso.ClassicEnum = avstantso._reg.ClassicEnum(({ JS }) => {
|
|
645
|
+
function entries(enumType) {
|
|
646
|
+
if (!enumType || !JS.is.object(enumType))
|
|
647
|
+
return [];
|
|
648
|
+
const entries = [];
|
|
649
|
+
for (const [k, v] of Object.entries(enumType))
|
|
650
|
+
if (!/^\d+$/.test(k))
|
|
651
|
+
entries.push([k, v]);
|
|
652
|
+
return entries;
|
|
653
|
+
}
|
|
654
|
+
return { entries };
|
|
655
|
+
});
|
|
656
|
+
})(AVStantso$1 || (AVStantso$1 = {}));
|
|
657
|
+
|
|
658
|
+
Object.definePropertiesOnce(AbortSignal.prototype, {
|
|
659
|
+
Safe: {
|
|
660
|
+
get() {
|
|
661
|
+
return avstantso.Stub.Custom((func) => ((...params) => this.aborted || !func ? undefined : func(...params)
|
|
662
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
663
|
+
));
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
var Perform = AVStantso.Perform;
|
|
669
|
+
var Provider = AVStantso.Provider;
|
|
670
|
+
var Compare = AVStantso.Compare;
|
|
671
|
+
var Equality = AVStantso.Equality;
|
|
672
|
+
var Extend = AVStantso.Extend;
|
|
673
|
+
var Switch = AVStantso.Switch;
|
|
674
|
+
var Stub = AVStantso.Stub;
|
|
675
|
+
var Mock = AVStantso.Mock;
|
|
676
|
+
var Mapping = AVStantso.Mapping;
|
|
677
|
+
var Conveyor = AVStantso.Conveyor;
|
|
678
|
+
var Override = AVStantso.Override;
|
|
679
|
+
var Transition = AVStantso.Transition;
|
|
680
|
+
var AsyncTasksManager = AVStantso.AsyncTasksManager;
|
|
681
|
+
var ClassicEnum = AVStantso.ClassicEnum;
|
|
682
|
+
var ValueWrap = AVStantso_ValueWrap;
|
|
683
|
+
|
|
684
|
+
exports.AsyncTasksManager = AsyncTasksManager;
|
|
685
|
+
exports.ClassicEnum = ClassicEnum;
|
|
686
|
+
exports.Compare = Compare;
|
|
687
|
+
exports.Conveyor = Conveyor;
|
|
688
|
+
exports.Equality = Equality;
|
|
689
|
+
exports.Extend = Extend;
|
|
690
|
+
exports.Mapping = Mapping;
|
|
691
|
+
exports.Mock = Mock;
|
|
692
|
+
exports.Override = Override;
|
|
693
|
+
exports.Perform = Perform;
|
|
694
|
+
exports.Provider = Provider;
|
|
695
|
+
exports.Stub = Stub;
|
|
696
|
+
exports.Switch = Switch;
|
|
697
|
+
exports.Transition = Transition;
|
|
698
|
+
exports.ValueWrap = ValueWrap;
|
|
699
|
+
//# sourceMappingURL=index.js.map
|