@avstantso/concepts 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +98 -0
- package/package.json +6 -6
- package/dist/_global/async-tasks.d.ts +0 -134
- package/dist/_global/classic-enum.d.ts +0 -29
- package/dist/_global/compare/_register.d.ts +0 -32
- package/dist/_global/compare/combination.d.ts +0 -41
- package/dist/_global/compare/compare.d.ts +0 -39
- package/dist/_global/compare/index.d.ts +0 -4
- package/dist/_global/compare/structures.d.ts +0 -10
- package/dist/_global/conveyor.d.ts +0 -18
- package/dist/_global/equality/_register.d.ts +0 -35
- package/dist/_global/equality/equality.d.ts +0 -32
- package/dist/_global/equality/index.d.ts +0 -2
- package/dist/_global/extend/_register.d.ts +0 -76
- package/dist/_global/extend/index.d.ts +0 -1
- package/dist/_global/index.d.ts +0 -15
- package/dist/_global/mapping/_register.d.ts +0 -59
- package/dist/_global/mapping/index.d.ts +0 -2
- package/dist/_global/mapping/mapping.d.ts +0 -138
- package/dist/_global/mock.d.ts +0 -11
- package/dist/_global/override.d.ts +0 -50
- package/dist/_global/perform/_register.d.ts +0 -107
- package/dist/_global/perform/index.d.ts +0 -1
- package/dist/_global/provider/_register.d.ts +0 -16
- package/dist/_global/provider/combination.d.ts +0 -96
- package/dist/_global/provider/compare.d.ts +0 -47
- package/dist/_global/provider/extract.d.ts +0 -36
- package/dist/_global/provider/force.d.ts +0 -35
- package/dist/_global/provider/index.d.ts +0 -10
- package/dist/_global/provider/is.d.ts +0 -38
- package/dist/_global/provider/provider.d.ts +0 -85
- package/dist/_global/provider/strict.d.ts +0 -29
- package/dist/_global/provider/union.d.ts +0 -29
- package/dist/_global/provider/value.d.ts +0 -26
- package/dist/_global/stub.d.ts +0 -40
- package/dist/_global/switch/_register.d.ts +0 -45
- package/dist/_global/switch/index.d.ts +0 -2
- package/dist/_global/switch/switch.d.ts +0 -13
- package/dist/_global/transition.d.ts +0 -62
- package/dist/_global/value-wrap.d.ts +0 -12
- package/dist/export.d.ts +0 -16
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -689
- package/dist/index.js.map +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Code {
|
|
3
|
-
namespace Mapping {
|
|
4
|
-
/**
|
|
5
|
-
* @summary Mapping factoru function
|
|
6
|
-
*/
|
|
7
|
-
interface Factory<TMap extends object, TProviderFiled extends AVStantso.Mapping.ProviderKey<TMap> = undefined> {
|
|
8
|
-
<TTemplate extends AVStantso.Mapping.Template<TMap>, TValueBase extends AVStantso.Mapping.ValueBase<TMap, TProviderFiled> = AVStantso.Mapping.ValueBase<TMap, TProviderFiled>, TValueUnionBase extends AVStantso.Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase> = AVStantso.Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase>>(template: TTemplate): AVStantso.Mapping<TMap, TTemplate, TProviderFiled, TValueBase, TValueUnionBase>;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @summary Mapping helpers utility
|
|
13
|
-
*/
|
|
14
|
-
interface Mapping {
|
|
15
|
-
/**
|
|
16
|
-
* @summary Find in `TTemplate` of the specified type a property with a name corresponding to `TMap` type
|
|
17
|
-
* - by value of `TMap[keyof TMap] | TMap[keyof TMap][TProviderFiled]` (with `TProviderFiled`) *
|
|
18
|
-
* @template TMap Type of map for create `Mapping.Factory` function
|
|
19
|
-
* @template TProviderFiled Type of provider field
|
|
20
|
-
* @param field Provider field. If `undefined` — provider values not supports
|
|
21
|
-
* @param keyFromValue Get key from value function
|
|
22
|
-
* @param map Source of `TMap` type parameter. Not used in runtime
|
|
23
|
-
*/
|
|
24
|
-
<TMap extends object, TProviderFiled extends AVStantso.Mapping.ProviderKey<TMap> = undefined>(field: TProviderFiled, keyFromValue: AVStantso.Mapping.KeyFromValue<TMap>, map?: TMap): Mapping.Factory<TMap, TProviderFiled>;
|
|
25
|
-
/**
|
|
26
|
-
* @summary Find in `TTemplate` of the specified type a property with a name corresponding to `TMap` type
|
|
27
|
-
* - by value of `TMap[keyof TMap]` (without `TProviderFiled`)
|
|
28
|
-
* @template TMap Type of map for create `Mapping.Factory` function
|
|
29
|
-
* @param keyFromValue Get key from value function
|
|
30
|
-
* @param map Source of `TMap` type parameter. Not used in runtime
|
|
31
|
-
*/
|
|
32
|
-
<TMap extends object>(keyFromValue: AVStantso.Mapping.KeyFromValue<TMap>, map?: TMap): Mapping.Factory<TMap>;
|
|
33
|
-
/**
|
|
34
|
-
* @summary Find in `TTemplate` of the specified type a property with a name corresponding to `TMap` type
|
|
35
|
-
* - by value of `TMap[keyof TMap] | TMap[keyof TMap][TProviderFiled]` (with `TProviderFiled`) *
|
|
36
|
-
* @template TMap Type of map for create `Mapping.Factory` function
|
|
37
|
-
* @template TProviderFiled Type of provider field
|
|
38
|
-
* @param field Provider field. If `undefined` — provider values not supports
|
|
39
|
-
* @param map Source of `TMap` type parameter
|
|
40
|
-
*/
|
|
41
|
-
<TMap extends object, TProviderFiled extends AVStantso.Mapping.ProviderKey<TMap>>(field: TProviderFiled, map: TMap): Mapping.Factory<TMap, TProviderFiled>;
|
|
42
|
-
/**
|
|
43
|
-
* @summary Find in `TTemplate` of the specified type a property with a name corresponding to `TMap` type
|
|
44
|
-
* - by value of `TMap[keyof TMap]` (without `TProviderFiled`)
|
|
45
|
-
* @template TMap Type of map for create `Mapping.Factory` function
|
|
46
|
-
* @param keyFromValue Get key from value function
|
|
47
|
-
* @param map Source of `TMap` type parameter
|
|
48
|
-
*/
|
|
49
|
-
<TMap extends object>(map: TMap): Mapping.Factory<TMap>;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
interface Code {
|
|
53
|
-
/**
|
|
54
|
-
* @summary Mapping helpers utility
|
|
55
|
-
*/
|
|
56
|
-
Mapping: Code.Mapping;
|
|
57
|
-
}
|
|
58
|
-
const Mapping: Code.Mapping;
|
|
59
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
/**
|
|
3
|
-
* Debug mode for package developer
|
|
4
|
-
*/
|
|
5
|
-
type Debug = false;
|
|
6
|
-
export namespace Mapping {
|
|
7
|
-
/**
|
|
8
|
-
* @summary Get key by value method
|
|
9
|
-
*/
|
|
10
|
-
type KeyFromValue<TMap extends object, TKey extends keyof TMap = keyof TMap, TValue extends TMap[TKey] = TMap[TKey]> = ((value: TValue) => TKey);
|
|
11
|
-
/**
|
|
12
|
-
* @summary Mapping `TTemplate` constraint
|
|
13
|
-
*/
|
|
14
|
-
type Template<TMap extends object> = Partial<Record<keyof TMap, unknown>>;
|
|
15
|
-
/**
|
|
16
|
-
* @summary Mapping `TProviderFiled` constraint
|
|
17
|
-
*/
|
|
18
|
-
type ProviderKey<TMap extends object> = keyof TMap[keyof TMap];
|
|
19
|
-
/**
|
|
20
|
-
* @summary Mapping `TValueBase` constraint
|
|
21
|
-
*/
|
|
22
|
-
type ValueBase<TMap extends object, TProviderFiled extends ProviderKey<TMap>> = TMap[keyof TMap] | (TProviderFiled extends undefined ? never : TMap[keyof TMap][TProviderFiled]);
|
|
23
|
-
/**
|
|
24
|
-
* @summary Mapping `TValueUnionBase` constraint
|
|
25
|
-
*/
|
|
26
|
-
type ValueUnionBase<TMap extends object, TProviderFiled extends ProviderKey<TMap>, TValueBase extends ValueBase<TMap, TProviderFiled> = ValueBase<TMap, TProviderFiled>> = TProviderFiled extends undefined ? TValueBase : Provider.Union.Make<TProviderFiled, TValueBase>;
|
|
27
|
-
}
|
|
28
|
-
type _ValueOfField<TMap extends object, TProviderFiled extends Mapping.ProviderKey<TMap>, TValueBase extends Mapping.ValueBase<TMap, TProviderFiled> = Mapping.ValueBase<TMap, TProviderFiled>, TValue extends Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase> = Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase>> = TProviderFiled extends undefined ? TValue : TValue extends Provider.Union<Provider<TProviderFiled, TValueBase>> ? Provider.Value.Make<TValue, TProviderFiled, TValueBase> : never;
|
|
29
|
-
type _Result<TMap extends object, TTemplate extends Mapping.Template<TMap>, TProviderFiled extends Mapping.ProviderKey<TMap>, TValueBase extends Mapping.ValueBase<TMap, TProviderFiled>, TReversedMap extends TS.Structure.Reverse<TMap, TProviderFiled>, TValue extends Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase>, TExclude extends Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase>, VF extends _ValueOfField<TMap, TProviderFiled, TValueBase, TValue> = _ValueOfField<TMap, TProviderFiled, TValueBase, TValue>, EF extends _ValueOfField<TMap, TProviderFiled, TValueBase, TExclude> = _ValueOfField<TMap, TProviderFiled, TValueBase, TExclude>, V extends Exclude<VF, EF> = Exclude<VF, EF>, MK extends Extract<V, keyof TReversedMap> = Extract<V, keyof TReversedMap>, TK extends Extract<TReversedMap[MK], keyof TTemplate> = Extract<TReversedMap[MK], keyof TTemplate>, R extends TTemplate[TK] = TTemplate[TK]> = {
|
|
30
|
-
TProviderFiled: TProviderFiled;
|
|
31
|
-
TValueBase: TValueBase;
|
|
32
|
-
TValue: TValue;
|
|
33
|
-
TExclude: TExclude;
|
|
34
|
-
VF: VF;
|
|
35
|
-
EF: EF;
|
|
36
|
-
V: V;
|
|
37
|
-
MK: MK;
|
|
38
|
-
TK: TK;
|
|
39
|
-
R: R;
|
|
40
|
-
TReversedMap: {
|
|
41
|
-
[K in keyof TReversedMap]: TReversedMap[K];
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @summary Find in `TTemplate` of the specified type a property with a name corresponding to `TMap` type
|
|
46
|
-
* - by value of `TMap[keyof TMap]` (without `TProviderFiled`)
|
|
47
|
-
* - by value of `TMap[keyof TMap] | TMap[keyof TMap][TProviderFiled]` (with `TProviderFiled`)
|
|
48
|
-
* @template TMap Source map for matching
|
|
49
|
-
* @template TTemplate Template for matching
|
|
50
|
-
* @template TProviderFiled Optionally `TMap` subfield for matching
|
|
51
|
-
* @template TValueBase Base value type.
|
|
52
|
-
* @template TValueUnionBase Base value provider union type.
|
|
53
|
-
* @template TInferReversedMap Сalculated `value-key` reversed `TMap`. ⛔ Don`t need set manually
|
|
54
|
-
* @returns Function type for finding. ⛔ Don`t need set it`s templates manually
|
|
55
|
-
* @example
|
|
56
|
-
* namespace PlatformerAction {
|
|
57
|
-
* export type Move = (x: number, scream: string) => Promise<unknown>;
|
|
58
|
-
* export type Jump = (y: number, spin: boolean) => Promise<unknown>;
|
|
59
|
-
* export type NoMove = (sound: object) => Promise<unknown>;
|
|
60
|
-
* }
|
|
61
|
-
* type PlatformerAction = {
|
|
62
|
-
* top: PlatformerAction.Jump;
|
|
63
|
-
* left: PlatformerAction.Move;
|
|
64
|
-
* bottom: PlatformerAction.NoMove;
|
|
65
|
-
* right: PlatformerAction.Move;
|
|
66
|
-
* center: PlatformerAction.NoMove;
|
|
67
|
-
* };
|
|
68
|
-
*
|
|
69
|
-
* //#region Simple
|
|
70
|
-
* type SimpleEnum = {
|
|
71
|
-
* top: 1;
|
|
72
|
-
* left: 2;
|
|
73
|
-
* bottom: 3;
|
|
74
|
-
* right: 4;
|
|
75
|
-
* center: -1;
|
|
76
|
-
* };
|
|
77
|
-
*
|
|
78
|
-
* type SimpleMapping = Mapping<SimpleEnum, PlatformerAction>;
|
|
79
|
-
* // Implementation not metter for this example
|
|
80
|
-
* const simpleMapper = (() => null as null) as unknown as SimpleMapping;
|
|
81
|
-
*
|
|
82
|
-
* const SIMPLE_RESULTS = {
|
|
83
|
-
* top: simpleMapper(1),
|
|
84
|
-
* left: simpleMapper(2),
|
|
85
|
-
* bottom: simpleMapper(3),
|
|
86
|
-
* right: simpleMapper(4),
|
|
87
|
-
* center: simpleMapper(-1)
|
|
88
|
-
* };
|
|
89
|
-
*
|
|
90
|
-
* type SimpleResults = typeof SIMPLE_RESULTS;
|
|
91
|
-
*
|
|
92
|
-
* type SimpleChecks = [
|
|
93
|
-
* CheckType<SimpleResults['top'], PlatformerAction.Jump>,
|
|
94
|
-
* CheckType<SimpleResults['left'], PlatformerAction.Move>,
|
|
95
|
-
* CheckType<SimpleResults['bottom'], PlatformerAction.NoMove>,
|
|
96
|
-
* CheckType<SimpleResults['right'], PlatformerAction.Move>,
|
|
97
|
-
* CheckType<SimpleResults['center'], PlatformerAction.NoMove>
|
|
98
|
-
* ];
|
|
99
|
-
* //#endregion
|
|
100
|
-
*
|
|
101
|
-
* //#region Complex
|
|
102
|
-
* type ComplexEnum = {
|
|
103
|
-
* top: { value: 1, sign: '↑' };
|
|
104
|
-
* left: { value: 2, sign: '←' };
|
|
105
|
-
* bottom: { value: 3, sign: '↓' };
|
|
106
|
-
* right: { value: 4, sign: '→' };
|
|
107
|
-
* center: { value: -1, sign: '⊕' };
|
|
108
|
-
* };
|
|
109
|
-
*
|
|
110
|
-
* type ComplexMapping = Mapping<ComplexEnum, PlatformerAction, 'value'>;
|
|
111
|
-
*
|
|
112
|
-
* // Implementation not metter for this example
|
|
113
|
-
* const complexMapper = (() => null as null) as unknown as ComplexMapping;
|
|
114
|
-
*
|
|
115
|
-
* const COMPLEX_RESULTS = {
|
|
116
|
-
* top: complexMapper(1),
|
|
117
|
-
* left: complexMapper(2),
|
|
118
|
-
* bottom: complexMapper(3),
|
|
119
|
-
* right: complexMapper(4),
|
|
120
|
-
* center: complexMapper(-1)
|
|
121
|
-
* };
|
|
122
|
-
*
|
|
123
|
-
* type ComplexResults = typeof COMPLEX_RESULTS;
|
|
124
|
-
*
|
|
125
|
-
* type ComplexChecks = [
|
|
126
|
-
* CheckType<ComplexResults['top'], PlatformerAction.Jump>,
|
|
127
|
-
* CheckType<ComplexResults['left'], PlatformerAction.Move>,
|
|
128
|
-
* CheckType<ComplexResults['bottom'], PlatformerAction.NoMove>,
|
|
129
|
-
* CheckType<ComplexResults['right'], PlatformerAction.Move>,
|
|
130
|
-
* CheckType<ComplexResults['center'], PlatformerAction.NoMove>
|
|
131
|
-
* ];
|
|
132
|
-
* //#endregion
|
|
133
|
-
*/
|
|
134
|
-
export type Mapping<TMap extends object, TTemplate extends Mapping.Template<TMap>, TProviderFiled extends Mapping.ProviderKey<TMap> = undefined, TValueBase extends Mapping.ValueBase<TMap, TProviderFiled> = Mapping.ValueBase<TMap, TProviderFiled>, TValueUnionBase extends Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase> = Mapping.ValueUnionBase<TMap, TProviderFiled, TValueBase>, TInferReversedMap extends TS.Structure.Reverse<TMap, TProviderFiled> = TS.Structure.Reverse<TMap, TProviderFiled>> = [keyof TInferReversedMap] extends [never] ? 'TMap must have values statisfy TS.Key or TMap[keyof TMap][TProviderFiled] must statisfy TS.Key' : <TInferValue extends TValueUnionBase, TInferExclude extends TValueUnionBase = never, TInferResult extends _Result<TMap, TTemplate, TProviderFiled, TValueBase, TInferReversedMap, TInferValue, TInferExclude> = _Result<TMap, TTemplate, TProviderFiled, TValueBase, TInferReversedMap, TInferValue, TInferExclude>>(value: TInferValue, exclude?: TInferExclude) => Debug extends true ? {
|
|
135
|
-
[K in keyof TInferResult]: TInferResult[K];
|
|
136
|
-
} : TInferResult['R'];
|
|
137
|
-
export {};
|
|
138
|
-
}
|
package/dist/_global/mock.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
interface Code {
|
|
3
|
-
/**
|
|
4
|
-
* @summary Mock any props of `source`\
|
|
5
|
-
* as empty function or `undefied` non function\
|
|
6
|
-
* if not `doNotUseMocking`
|
|
7
|
-
*/
|
|
8
|
-
Mock<T extends NodeJS.Dict<unknown>>(source?: T, doNotUseMocking?: boolean): T;
|
|
9
|
-
}
|
|
10
|
-
const Mock: Code['Mock'];
|
|
11
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
/**
|
|
3
|
-
* @summary Override value structure.
|
|
4
|
-
* In `Calculator` if `override === undefined` will be used `original`
|
|
5
|
-
*/
|
|
6
|
-
namespace Override {
|
|
7
|
-
namespace TypeMap {
|
|
8
|
-
type OrT = TypeMap | TS.Type.Not.Function;
|
|
9
|
-
type Parse<T extends OrT> = T extends TypeMap ? T : {
|
|
10
|
-
T: T;
|
|
11
|
-
Ext?: undefined;
|
|
12
|
-
};
|
|
13
|
-
type IsSimple<T extends OrT, IfTrue = true, IfFalse = false> = TypeMap.Parse<T>['Ext'] extends undefined ? IfTrue : IfFalse;
|
|
14
|
-
}
|
|
15
|
-
type TypeMap = {
|
|
16
|
-
T: TS.Type.Not.Function;
|
|
17
|
-
Ext?: {};
|
|
18
|
-
};
|
|
19
|
-
type Context<TTypeMapOrT extends TypeMap.OrT> = {
|
|
20
|
-
original: TypeMap.Parse<TTypeMapOrT>['T'];
|
|
21
|
-
} & TypeMap.IsSimple<TTypeMapOrT, {}, TypeMap.Parse<TTypeMapOrT>['Ext']>;
|
|
22
|
-
type Union<TTypeMapOrT extends TypeMap.OrT> = TypeMap.Parse<TTypeMapOrT>['T'] | Override<TTypeMapOrT>;
|
|
23
|
-
namespace Calculator {
|
|
24
|
-
type Calulate<TTypeMapOrT extends TypeMap.OrT> = (override?: Union<TTypeMapOrT>) => TypeMap.Parse<TTypeMapOrT>['T'];
|
|
25
|
-
}
|
|
26
|
-
type Calculator<TTypeMapOrT extends TypeMap.OrT> = TypeMap.IsSimple<TTypeMapOrT, (context?: Context<TTypeMapOrT> | TypeMap.Parse<TTypeMapOrT>['T']) => Calculator.Calulate<TTypeMapOrT>, (context?: Context<TTypeMapOrT>) => Calculator.Calulate<TTypeMapOrT>>;
|
|
27
|
-
}
|
|
28
|
-
type Override<TTypeMapOrT extends Override.TypeMap.OrT> = (context?: Override.Context<TTypeMapOrT>) => Override.TypeMap.Parse<TTypeMapOrT>['T'];
|
|
29
|
-
namespace Code {
|
|
30
|
-
/**
|
|
31
|
-
* @summary Override utils
|
|
32
|
-
*/
|
|
33
|
-
interface Override {
|
|
34
|
-
isContext<TTypeMapOrT extends Override.TypeMap.OrT = Override.TypeMap>(candidate: unknown): candidate is Override.Context<TTypeMapOrT>;
|
|
35
|
-
/**
|
|
36
|
-
* @summary Calculator of override value structure
|
|
37
|
-
*/
|
|
38
|
-
Calculator<TTypeMapOrT extends Override.TypeMap.OrT, TContextOrOriginal extends Override.Context<TTypeMapOrT> | Override.TypeMap.Parse<TTypeMapOrT>['T']>(context?: TContextOrOriginal): (override: Override.Union<TTypeMapOrT>) => TContextOrOriginal extends {
|
|
39
|
-
original: infer R;
|
|
40
|
-
} ? R : TContextOrOriginal;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
interface Code {
|
|
44
|
-
/**
|
|
45
|
-
* @summary Override utils
|
|
46
|
-
*/
|
|
47
|
-
Override: Code.Override;
|
|
48
|
-
}
|
|
49
|
-
const Override: Code.Override;
|
|
50
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
type SysPromise<T> = Promise<T>;
|
|
3
|
-
/**
|
|
4
|
-
* @summary Value or get value function
|
|
5
|
-
* @template T Value type
|
|
6
|
-
* @example
|
|
7
|
-
* expect(Perform(1)).toBe(1);
|
|
8
|
-
* expect(Perform(() => 2)).toBe(2);
|
|
9
|
-
* expect(Perform((m, n) => m * n, 3, 4)).toBe(12);
|
|
10
|
-
*
|
|
11
|
-
* let x = 0;
|
|
12
|
-
* expect(Perform((o, p, q) => o + p + q, {
|
|
13
|
-
* params: [1, 2, 3],
|
|
14
|
-
* afterCallback(r) {
|
|
15
|
-
* x += 3 * r;
|
|
16
|
-
* }
|
|
17
|
-
* })).toBe(6);
|
|
18
|
-
*
|
|
19
|
-
* expect(x).toBe(18);
|
|
20
|
-
*/
|
|
21
|
-
export type Perform<T, TParams extends TS.Arr = never> = TS.Func<T, TParams> | (T extends Function ? never : T);
|
|
22
|
-
export namespace Perform {
|
|
23
|
-
namespace Options {
|
|
24
|
-
type Is = <T, TParams extends TS.Arr = never>(candidate: unknown) => candidate is Perform.Options<T, TParams>;
|
|
25
|
-
}
|
|
26
|
-
interface Options<T, TParams extends TS.Arr = never> {
|
|
27
|
-
afterCallback?: (r?: T) => unknown;
|
|
28
|
-
params?: TParams;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Result of perform
|
|
32
|
-
* @template P Perform type
|
|
33
|
-
*/
|
|
34
|
-
type Result<P extends Perform<any, any>> = P extends TS.Func<infer R> ? R : Exclude<P, TS.Func>;
|
|
35
|
-
namespace Promise {
|
|
36
|
-
/**
|
|
37
|
-
* @summary Value or get value function. Value may be a `Promise<T>`
|
|
38
|
-
*/
|
|
39
|
-
type Sync<T, TParams extends TS.Arr = never> = Perform<T | SysPromise<T>, TParams>;
|
|
40
|
-
namespace Sync {
|
|
41
|
-
/**
|
|
42
|
-
* @summary Result of sync perform promise
|
|
43
|
-
* @template P Perform type
|
|
44
|
-
*/
|
|
45
|
-
type Result<P extends Sync<any, any>> = Awaited<Perform.Result<P>>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @summary Result of sync perform promise
|
|
49
|
-
* @template P Perform type
|
|
50
|
-
*/
|
|
51
|
-
type Result<P extends Perform.Promise<any, any>> = Perform.Result<Awaited<Sync.Result<P>>>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @summary Value or get value function or promise of value or promise of get value function
|
|
55
|
-
*/
|
|
56
|
-
type Promise<T, TParams extends TS.Arr = never> = Promise.Sync<T, TParams> | SysPromise<Perform<T, TParams>>;
|
|
57
|
-
}
|
|
58
|
-
export namespace Code {
|
|
59
|
-
namespace Perform {
|
|
60
|
-
interface Simple {
|
|
61
|
-
<T, TParams extends AVStantso.TS.Arr = never>(p: AVStantso.Perform<T, TParams>, ...params: TParams): T;
|
|
62
|
-
<T, TParams extends AVStantso.TS.Arr = never>(p: AVStantso.Perform<T, TParams>, options?: AVStantso.Perform.Options<T, TParams>): T;
|
|
63
|
-
}
|
|
64
|
-
interface List {
|
|
65
|
-
<T, TParams extends AVStantso.TS.Arr = never>(options: AVStantso.Perform.Options<T, TParams>, ...p: AVStantso.Perform<T | T[], TParams>[]): T[];
|
|
66
|
-
<T, TParams extends AVStantso.TS.Arr = never>(...p: AVStantso.Perform<T | T[], TParams>[]): T[];
|
|
67
|
-
}
|
|
68
|
-
namespace Promise {
|
|
69
|
-
interface Simple {
|
|
70
|
-
<T, TParams extends AVStantso.TS.Arr = never>(p: AVStantso.Perform.Promise<T, TParams>, ...params: TParams): SysPromise<T>;
|
|
71
|
-
<T, TParams extends AVStantso.TS.Arr = never>(p: AVStantso.Perform.Promise<T, TParams>, options?: AVStantso.Perform.Options<T, TParams>): SysPromise<T>;
|
|
72
|
-
}
|
|
73
|
-
interface List {
|
|
74
|
-
<T, TParams extends AVStantso.TS.Arr = never>(options: AVStantso.Perform.Options<T, TParams>, ...p: AVStantso.Perform.Promise<T | T[], TParams>[]): SysPromise<T[]>;
|
|
75
|
-
<T, TParams extends AVStantso.TS.Arr = never>(...p: AVStantso.Perform.Promise<T | T[], TParams>[]): SysPromise<T[]>;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @summary `AVStantso.Perform.Promise` utility
|
|
80
|
-
*/
|
|
81
|
-
interface Promise extends Promise.Simple {
|
|
82
|
-
List: Promise.List;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @summary `AVStantso.Perform` utility
|
|
87
|
-
*/
|
|
88
|
-
interface Perform extends Perform.Simple {
|
|
89
|
-
Options: {
|
|
90
|
-
is: AVStantso.Perform.Options.Is;
|
|
91
|
-
};
|
|
92
|
-
List: Perform.List;
|
|
93
|
-
/**
|
|
94
|
-
* @summary `AVStantso.Perform.Promise` utility
|
|
95
|
-
*/
|
|
96
|
-
Promise: Perform.Promise;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export interface Code {
|
|
100
|
-
/**
|
|
101
|
-
* @summary `AVStantso.Perform` utility
|
|
102
|
-
*/
|
|
103
|
-
Perform: Code.Perform;
|
|
104
|
-
}
|
|
105
|
-
export const Perform: Code.Perform;
|
|
106
|
-
export {};
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './_register';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Code {
|
|
3
|
-
/**
|
|
4
|
-
* @summary `AVStantso.Provider` utility
|
|
5
|
-
*/
|
|
6
|
-
interface Provider {
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
interface Code {
|
|
10
|
-
/**
|
|
11
|
-
* @summary `AVStantso.Provider` utility
|
|
12
|
-
*/
|
|
13
|
-
Provider: Code.Provider;
|
|
14
|
-
}
|
|
15
|
-
const Provider: Code.Provider;
|
|
16
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Provider {
|
|
3
|
-
namespace _Combination {
|
|
4
|
-
type Restore<C, Keys extends TS.Keys = globalThis.Extract<TS.Union.ToTuple<keyof C>, TS.Keys>, R extends Combination.Constraint = {
|
|
5
|
-
__KEYS__?: Keys;
|
|
6
|
-
} & C> = {
|
|
7
|
-
[K in keyof R]: R[K];
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
type _Combination<PP extends Combination.Params, R = unknown> = PP extends readonly [
|
|
11
|
-
infer P extends Combination.Param,
|
|
12
|
-
...infer Rest extends Combination.Params
|
|
13
|
-
] ? P extends Provider.Constraint ? _Combination<Rest, R & Provider.Dry<P>> : P extends Combination.Constraint ? _Combination<Rest, R & Combination.Dry<P>> : never : _Combination.Restore<R>;
|
|
14
|
-
/**
|
|
15
|
-
* @summary Providers combination.\
|
|
16
|
-
* ⚠ Order of `__KEYS__` not warrant
|
|
17
|
-
* @template PP Array of providers or combinations
|
|
18
|
-
* @example
|
|
19
|
-
* type A = Provider<'a', string>;
|
|
20
|
-
* type B = Provider<'b', number>;
|
|
21
|
-
* type C = {
|
|
22
|
-
* __KEYS__: ['c', 'd', 'e'],
|
|
23
|
-
* c: bigint;
|
|
24
|
-
* d: object;
|
|
25
|
-
* e: unknown[];
|
|
26
|
-
* };
|
|
27
|
-
* type F = {
|
|
28
|
-
* __KEYS__: ['f'],
|
|
29
|
-
* f: () => symbol;
|
|
30
|
-
* };
|
|
31
|
-
*
|
|
32
|
-
* type R = CheckType<
|
|
33
|
-
* Combination<[A, B, C, F]>,
|
|
34
|
-
* {
|
|
35
|
-
* __KEYS__?: TS.Keys; // ⚠ Order of items not warrant, see below 👇 (RK)
|
|
36
|
-
* a: string;
|
|
37
|
-
* b: number;
|
|
38
|
-
* c: bigint;
|
|
39
|
-
* d: object;
|
|
40
|
-
* e: unknown[];
|
|
41
|
-
* f: () => symbol;
|
|
42
|
-
* }
|
|
43
|
-
* >;
|
|
44
|
-
*
|
|
45
|
-
* type RK = CheckType<
|
|
46
|
-
* TS.Array.Sort<globalThis.Extract<R[__KEYS__], string[]>>,
|
|
47
|
-
* ['a', 'b', 'c', 'd', 'e', 'f']
|
|
48
|
-
* >;
|
|
49
|
-
*/
|
|
50
|
-
export type Combination<PP extends Combination.Params> = _Combination<PP>;
|
|
51
|
-
export namespace Combination {
|
|
52
|
-
/**
|
|
53
|
-
* @summary Providers combination constraint
|
|
54
|
-
*/
|
|
55
|
-
export type Constraint = {
|
|
56
|
-
__KEYS__?: readonly TS.Key[];
|
|
57
|
-
} & {
|
|
58
|
-
[k: TS.Key]: unknown;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* @summary Providers combination param
|
|
62
|
-
*/
|
|
63
|
-
export type Param = Constraint | Provider.Constraint;
|
|
64
|
-
/**
|
|
65
|
-
* @summary Array of providers combination param
|
|
66
|
-
*/
|
|
67
|
-
export type Params = readonly Param[];
|
|
68
|
-
type _Dry<C extends Constraint, Keys extends TS.Keys = C[__KEYS__], R = unknown> = Keys extends readonly [infer K extends TS.Key, ...infer Rest extends TS.Keys] ? _Dry<C, Rest, R & Pick<C, K>> : {
|
|
69
|
-
[K in keyof R]: R[K];
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* @summary Dry combination without `__KEYS__` and extended fields
|
|
73
|
-
* @example
|
|
74
|
-
* type C = {
|
|
75
|
-
* __KEYS__: ['a', 'b'],
|
|
76
|
-
* a: number;
|
|
77
|
-
* b: string;
|
|
78
|
-
* c: boolean;
|
|
79
|
-
* };
|
|
80
|
-
*
|
|
81
|
-
* type D = CheckType<
|
|
82
|
-
* Dry<C>, {
|
|
83
|
-
* a: number;
|
|
84
|
-
* b: string;
|
|
85
|
-
*
|
|
86
|
-
* __KEYS__?: never;
|
|
87
|
-
* c?: never;
|
|
88
|
-
* }
|
|
89
|
-
* >;
|
|
90
|
-
*/
|
|
91
|
-
export type Dry<C extends Constraint> = _Dry<C>;
|
|
92
|
-
export {};
|
|
93
|
-
}
|
|
94
|
-
export {};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Provider {
|
|
3
|
-
/**
|
|
4
|
-
* @summary Compare two `Provider.Value` from `Provider.Union` function
|
|
5
|
-
* @template P `Provider`
|
|
6
|
-
* @see Provider type
|
|
7
|
-
*/
|
|
8
|
-
type Compare<P extends Provider.Constraint> = AVStantso.Compare<Union<P>>;
|
|
9
|
-
namespace Compare {
|
|
10
|
-
/**
|
|
11
|
-
* @summary Make compare two `Provider.Value` from `Provider.Union` function
|
|
12
|
-
* @template F First `Provider` param
|
|
13
|
-
* @template S Second `Provider` param
|
|
14
|
-
* @see Provider type
|
|
15
|
-
*/
|
|
16
|
-
type Make<F extends First, S = undefined> = Compare<Provider<F, S>>;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
namespace Code {
|
|
20
|
-
namespace Provider {
|
|
21
|
-
namespace Compare {
|
|
22
|
-
/**
|
|
23
|
-
* @summary `AVStantso.Provider.Compare` utility options
|
|
24
|
-
*/
|
|
25
|
-
type Options<A extends AVStantso.TS.Type.KLD = AVStantso.TS.Type.KLD> = {
|
|
26
|
-
/**
|
|
27
|
-
* @summary Extract value method
|
|
28
|
-
*/
|
|
29
|
-
extract?: AVStantso.Provider.Extract.Make<A>;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @summary `AVStantso.Provider.Compare` utility
|
|
34
|
-
*/
|
|
35
|
-
interface Compare {
|
|
36
|
-
<K extends AVStantso.TS.Key, L extends AVStantso.TS.Literal>(key: K, type?: L, options?: Compare.Options<AVStantso.TS.Type.KLD<K, L>>): AVStantso.Provider.Compare.Make<K, L>;
|
|
37
|
-
<Arr extends AVStantso.TS.Type.KLD>(def: Arr, options?: Compare.Options<Arr>): AVStantso.Provider.Compare.Make<Arr>;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
interface Provider {
|
|
41
|
-
/**
|
|
42
|
-
* @summary `AVStantso.Provider.Compare` utility
|
|
43
|
-
*/
|
|
44
|
-
Compare: Provider.Compare;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Provider {
|
|
3
|
-
/**
|
|
4
|
-
* @summary Extract `Provider.Value` from `Provider.Union` function
|
|
5
|
-
* @template P `Provider`
|
|
6
|
-
* @see Provider type
|
|
7
|
-
*/
|
|
8
|
-
type Extract<P extends Provider.Constraint> = <T extends Value<Union<P>, P>>(union: Union<P>) => T;
|
|
9
|
-
namespace Extract {
|
|
10
|
-
/**
|
|
11
|
-
* @summary Make extract `Provider.Value` from `Provider.Union` function
|
|
12
|
-
* @template F First `Provider` param
|
|
13
|
-
* @template S Second `Provider` param
|
|
14
|
-
* @see Provider type
|
|
15
|
-
*/
|
|
16
|
-
type Make<F extends First, S = undefined> = Extract<Provider<F, S>>;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
namespace Code {
|
|
20
|
-
namespace Provider {
|
|
21
|
-
/**
|
|
22
|
-
* @summary `AVStantso.Provider.Extract` utility
|
|
23
|
-
*/
|
|
24
|
-
interface Extract {
|
|
25
|
-
<K extends AVStantso.TS.Key, L extends AVStantso.TS.Literal>(key: K, type?: L): AVStantso.Provider.Extract.Make<K, L>;
|
|
26
|
-
<Arr extends AVStantso.TS.Type.KLD>(def: Arr): AVStantso.Provider.Extract.Make<Arr>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
interface Provider {
|
|
30
|
-
/**
|
|
31
|
-
* @summary `AVStantso.Provider.Extract` utility
|
|
32
|
-
*/
|
|
33
|
-
Extract: Provider.Extract;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Provider {
|
|
3
|
-
/**
|
|
4
|
-
* @summary Force cast to provider
|
|
5
|
-
*/
|
|
6
|
-
type Force<P extends Provider.Constraint> = <T extends object>(obj: T) => Partial<Provider.Dry<P>>;
|
|
7
|
-
namespace Force {
|
|
8
|
-
/**
|
|
9
|
-
* @summary Make Force cast to provider
|
|
10
|
-
* @template F First `Provider` param
|
|
11
|
-
* @template S Second `Provider` param
|
|
12
|
-
* @see Provider type
|
|
13
|
-
*/
|
|
14
|
-
type Make<F extends First, S = undefined> = Force<Provider<F, S>>;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
namespace Code {
|
|
18
|
-
namespace Provider {
|
|
19
|
-
/**
|
|
20
|
-
* @summary Force caster to provider
|
|
21
|
-
*/
|
|
22
|
-
interface Force {
|
|
23
|
-
<K extends AVStantso.TS.Key, L extends AVStantso.TS.Literal>(key: K, type?: L): AVStantso.Provider.Force.Make<K, L>;
|
|
24
|
-
<Arr extends AVStantso.TS.Type.KLD>(def: Arr): AVStantso.Provider.Force.Make<Arr>;
|
|
25
|
-
<P extends AVStantso.Provider.Constraint>(): AVStantso.Provider.Force<P>;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
interface Provider {
|
|
29
|
-
/**
|
|
30
|
-
* @summary Force caster to provider
|
|
31
|
-
*/
|
|
32
|
-
Force: Provider.Force;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
declare namespace AVStantso {
|
|
2
|
-
namespace Provider {
|
|
3
|
-
/**
|
|
4
|
-
* @summary A function signature of: `candidate` is `Provider` object
|
|
5
|
-
* @template P `Provider`
|
|
6
|
-
* @template K `Provider` infer key
|
|
7
|
-
* @template B `Provider` infer base type of `T`
|
|
8
|
-
* @see Provider type
|
|
9
|
-
*/
|
|
10
|
-
type Is<P extends Constraint, K extends globalThis.Extract<P[__KEY__], keyof P> = globalThis.Extract<P[__KEY__], keyof P>, B extends Pick<P, K> = Pick<P, K>> = <T extends B = B>(candidate: unknown) => candidate is T;
|
|
11
|
-
namespace Is {
|
|
12
|
-
/**
|
|
13
|
-
* @summary Make a function signature of: `candidate` is `Provider` object
|
|
14
|
-
* @template F First `Provider` param
|
|
15
|
-
* @template S Second `Provider` param
|
|
16
|
-
* @see Provider type
|
|
17
|
-
*/
|
|
18
|
-
type Make<F extends First, S = undefined> = Is<Provider<F, S>>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
namespace Code {
|
|
22
|
-
namespace Provider {
|
|
23
|
-
/**
|
|
24
|
-
* @summary `AVStantso.Provider.Is` utility
|
|
25
|
-
*/
|
|
26
|
-
interface Is {
|
|
27
|
-
<K extends AVStantso.TS.Key, L extends AVStantso.TS.Literal>(key: K, type?: L): AVStantso.Provider.Is.Make<K, L>;
|
|
28
|
-
<Arr extends AVStantso.TS.Type.KLD>(def: Arr): AVStantso.Provider.Is.Make<Arr>;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
interface Provider {
|
|
32
|
-
/**
|
|
33
|
-
* @summary `AVStantso.Provider.Is` utility
|
|
34
|
-
*/
|
|
35
|
-
Is: Provider.Is;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|