@aidc-toolkit/core 1.0.27-beta → 1.0.28-beta
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/type-helper.d.ts +23 -1
- package/dist/type-helper.d.ts.map +1 -1
- package/dist/type-helper.js +26 -1
- package/dist/type-helper.js.map +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/type-helper.ts +27 -1
- package/src/type.ts +49 -0
package/dist/type-helper.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function omit<T extends object, K extends keyof T>(o: T, ...keys:
|
|
|
37
37
|
*/
|
|
38
38
|
export declare function pick<T extends object, K extends keyof T>(o: T, ...keys: K[]): Pick<T, K>;
|
|
39
39
|
/**
|
|
40
|
-
* Create an object
|
|
40
|
+
* Create an object from a wide object without entries matching those from a narrow object.
|
|
41
41
|
*
|
|
42
42
|
* @template TWide
|
|
43
43
|
* Wide object type.
|
|
@@ -58,6 +58,28 @@ export declare function pick<T extends object, K extends keyof T>(o: T, ...keys:
|
|
|
58
58
|
* Edited object.
|
|
59
59
|
*/
|
|
60
60
|
export declare function exclude<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Omit<TWide, K>;
|
|
61
|
+
/**
|
|
62
|
+
* Create an object from a wide object with entries matching those from a narrow object.
|
|
63
|
+
*
|
|
64
|
+
* @template TWide
|
|
65
|
+
* Wide object type.
|
|
66
|
+
*
|
|
67
|
+
* @template TNarrow
|
|
68
|
+
* Narrow object type.
|
|
69
|
+
*
|
|
70
|
+
* @template K
|
|
71
|
+
* Narrow object key type, subset of wide object key type.
|
|
72
|
+
*
|
|
73
|
+
* @param wide
|
|
74
|
+
* Wide object.
|
|
75
|
+
*
|
|
76
|
+
* @param narrow
|
|
77
|
+
* Narrow object.
|
|
78
|
+
*
|
|
79
|
+
* @returns
|
|
80
|
+
* Edited object.
|
|
81
|
+
*/
|
|
82
|
+
export declare function include<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Pick<TWide, K>;
|
|
61
83
|
/**
|
|
62
84
|
* Cast a property as a more narrow type.
|
|
63
85
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-helper.d.ts","sourceRoot":"","sources":["../src/type-helper.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAExF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAExF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAS,OAAO,EAAE,OAAO,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAG5I;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CA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SAAS,MAAM,CAAC,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CASrL;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,IAAI,GAAG,SAAS,CAEzE"}
|
package/dist/type-helper.js
CHANGED
|
@@ -69,7 +69,7 @@ export function pick(o, ...keys) {
|
|
|
69
69
|
return omitOrPick(false, o, ...keys);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Create an object
|
|
72
|
+
* Create an object from a wide object without entries matching those from a narrow object.
|
|
73
73
|
*
|
|
74
74
|
* @template TWide
|
|
75
75
|
* Wide object type.
|
|
@@ -93,6 +93,31 @@ export function exclude(wide, narrow) {
|
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Keys are valid.
|
|
94
94
|
return omit(wide, ...Object.keys(narrow));
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an object from a wide object with entries matching those from a narrow object.
|
|
98
|
+
*
|
|
99
|
+
* @template TWide
|
|
100
|
+
* Wide object type.
|
|
101
|
+
*
|
|
102
|
+
* @template TNarrow
|
|
103
|
+
* Narrow object type.
|
|
104
|
+
*
|
|
105
|
+
* @template K
|
|
106
|
+
* Narrow object key type, subset of wide object key type.
|
|
107
|
+
*
|
|
108
|
+
* @param wide
|
|
109
|
+
* Wide object.
|
|
110
|
+
*
|
|
111
|
+
* @param narrow
|
|
112
|
+
* Narrow object.
|
|
113
|
+
*
|
|
114
|
+
* @returns
|
|
115
|
+
* Edited object.
|
|
116
|
+
*/
|
|
117
|
+
export function include(wide, narrow) {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Keys are valid.
|
|
119
|
+
return pick(wide, ...Object.keys(narrow));
|
|
120
|
+
}
|
|
96
121
|
/**
|
|
97
122
|
* Cast a property as a more narrow type.
|
|
98
123
|
*
|
package/dist/type-helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-helper.js","sourceRoot":"","sources":["../src/type-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,UAAU,CAAgE,QAAkB,EAAE,CAAI,EAAE,GAAG,IAAS;IACrH,yGAAyG;IACzG,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAQ,CAAC,KAAK,QAAQ,CAAC,CAAkD,CAAC;AAC1J,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAsC,CAAI,EAAE,GAAG,IAAS;IACxE,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAsC,CAAI,EAAE,GAAG,IAAS;IACxE,OAAO,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,OAAO,CAAyE,IAAW,EAAE,MAAe;IACxH,0FAA0F;IAC1F,OAAO,IAAI,CAAC,IAAI,EAAE,GAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAS,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,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IAAI,EAAE,GAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAS,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,OAAO,CAAyE,IAAW,EAAE,MAAe;IACxH,0FAA0F;IAC1F,OAAO,IAAI,CAAC,IAAI,EAAE,GAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAS,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CAA4D,CAAI,EAAE,GAAM;IAC9F,2GAA2G;IAC3G,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACd;YACI,sFAAsF;YACtF,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAY;SAC3B,CAAC,CAAC;QACH,EAAE,CAC2C,CAAC;AACtD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,QAAiB;IACvC,OAAO,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,CAAC;AACvD,CAAC"}
|
package/dist/type.d.ts
CHANGED
|
@@ -12,6 +12,43 @@ export type TypedFunction<TFunction extends (...args: Parameters<TFunction>) =>
|
|
|
12
12
|
* Function type.
|
|
13
13
|
*/
|
|
14
14
|
export type TypedSyncFunction<TFunction extends TypedFunction<TFunction>> = [ReturnType<TFunction>] extends [PromiseLike<unknown>] ? never : TypedFunction<TFunction>;
|
|
15
|
+
/**
|
|
16
|
+
* Arbitrary constructor. An arbitrary constructor doesn't have to be an exact match to a constructor; the only
|
|
17
|
+
* requirements are that `TConstructorParameters` have compatible types (exact or wider types of the actual constructor
|
|
18
|
+
* parameters) and that `TConstructorInstance` be a compatible type (exact or narrower type of the actual constructor
|
|
19
|
+
* instance).
|
|
20
|
+
*
|
|
21
|
+
* @template TConstructorParameters
|
|
22
|
+
* Constructor parameters types.
|
|
23
|
+
*
|
|
24
|
+
* @template TConstructorInstance
|
|
25
|
+
* Constructor instance type.
|
|
26
|
+
*/
|
|
27
|
+
export type Constructor<TConstructorParameters extends unknown[], TConstructorInstance> = new (...args: TConstructorParameters) => TConstructorInstance;
|
|
28
|
+
/**
|
|
29
|
+
* Arbitrary abstract constructor. Abstract version of {@linkcode Constructor}.
|
|
30
|
+
*
|
|
31
|
+
* @template TConstructorParameters
|
|
32
|
+
* Constructor parameters types.
|
|
33
|
+
*
|
|
34
|
+
* @template TConstructorInstance
|
|
35
|
+
* Constructor instance type.
|
|
36
|
+
*/
|
|
37
|
+
export type AbstractConstructor<TConstructorParameters extends unknown[], TConstructorInstance> = abstract new (...args: TConstructorParameters) => TConstructorInstance;
|
|
38
|
+
/**
|
|
39
|
+
* Typed constructor, applicable to any constructor.
|
|
40
|
+
*
|
|
41
|
+
* @template TConstructor
|
|
42
|
+
* Constructor type.
|
|
43
|
+
*/
|
|
44
|
+
export type TypedConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> = Constructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
|
|
45
|
+
/**
|
|
46
|
+
* Typed abstract constructor, applicable to any constructor.
|
|
47
|
+
*
|
|
48
|
+
* @template TConstructor
|
|
49
|
+
* Constructor type.
|
|
50
|
+
*/
|
|
51
|
+
export type TypedAbstractConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> = AbstractConstructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
|
|
15
52
|
/**
|
|
16
53
|
* Determine the fundamental promised type. This is stricter than `Awaited<Type>` in that it requires a {@linkcode
|
|
17
54
|
* Promise}.
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU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,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,KAAK;CACxE,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28-beta",
|
|
4
4
|
"description": "Core functionality for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build:doc": "npm run build:dev"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@aidc-toolkit/dev": "1.0.
|
|
29
|
+
"@aidc-toolkit/dev": "1.0.28-beta"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"i18next": "^25.7.2",
|
package/src/type-helper.ts
CHANGED
|
@@ -72,7 +72,7 @@ export function pick<T extends object, K extends keyof T>(o: T, ...keys: K[]): P
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* Create an object
|
|
75
|
+
* Create an object from a wide object without entries matching those from a narrow object.
|
|
76
76
|
*
|
|
77
77
|
* @template TWide
|
|
78
78
|
* Wide object type.
|
|
@@ -97,6 +97,32 @@ export function exclude<TWide extends TNarrow, TNarrow extends object, K extends
|
|
|
97
97
|
return omit(wide, ...(Object.keys(narrow) as K[]));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Create an object from a wide object with entries matching those from a narrow object.
|
|
102
|
+
*
|
|
103
|
+
* @template TWide
|
|
104
|
+
* Wide object type.
|
|
105
|
+
*
|
|
106
|
+
* @template TNarrow
|
|
107
|
+
* Narrow object type.
|
|
108
|
+
*
|
|
109
|
+
* @template K
|
|
110
|
+
* Narrow object key type, subset of wide object key type.
|
|
111
|
+
*
|
|
112
|
+
* @param wide
|
|
113
|
+
* Wide object.
|
|
114
|
+
*
|
|
115
|
+
* @param narrow
|
|
116
|
+
* Narrow object.
|
|
117
|
+
*
|
|
118
|
+
* @returns
|
|
119
|
+
* Edited object.
|
|
120
|
+
*/
|
|
121
|
+
export function include<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Pick<TWide, K> {
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Keys are valid.
|
|
123
|
+
return pick(wide, ...(Object.keys(narrow) as K[]));
|
|
124
|
+
}
|
|
125
|
+
|
|
100
126
|
/**
|
|
101
127
|
* Cast a property as a more narrow type.
|
|
102
128
|
*
|
package/src/type.ts
CHANGED
|
@@ -14,6 +14,55 @@ export type TypedFunction<TFunction extends (...args: Parameters<TFunction>) =>
|
|
|
14
14
|
*/
|
|
15
15
|
export type TypedSyncFunction<TFunction extends TypedFunction<TFunction>> = [ReturnType<TFunction>] extends [PromiseLike<unknown>] ? never : TypedFunction<TFunction>;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Arbitrary constructor. An arbitrary constructor doesn't have to be an exact match to a constructor; the only
|
|
19
|
+
* requirements are that `TConstructorParameters` have compatible types (exact or wider types of the actual constructor
|
|
20
|
+
* parameters) and that `TConstructorInstance` be a compatible type (exact or narrower type of the actual constructor
|
|
21
|
+
* instance).
|
|
22
|
+
*
|
|
23
|
+
* @template TConstructorParameters
|
|
24
|
+
* Constructor parameters types.
|
|
25
|
+
*
|
|
26
|
+
* @template TConstructorInstance
|
|
27
|
+
* Constructor instance type.
|
|
28
|
+
*/
|
|
29
|
+
export type Constructor<
|
|
30
|
+
TConstructorParameters extends unknown[],
|
|
31
|
+
TConstructorInstance
|
|
32
|
+
> = new (...args: TConstructorParameters) => TConstructorInstance;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Arbitrary abstract constructor. Abstract version of {@linkcode Constructor}.
|
|
36
|
+
*
|
|
37
|
+
* @template TConstructorParameters
|
|
38
|
+
* Constructor parameters types.
|
|
39
|
+
*
|
|
40
|
+
* @template TConstructorInstance
|
|
41
|
+
* Constructor instance type.
|
|
42
|
+
*/
|
|
43
|
+
export type AbstractConstructor<
|
|
44
|
+
TConstructorParameters extends unknown[],
|
|
45
|
+
TConstructorInstance
|
|
46
|
+
> = abstract new (...args: TConstructorParameters) => TConstructorInstance;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Typed constructor, applicable to any constructor.
|
|
50
|
+
*
|
|
51
|
+
* @template TConstructor
|
|
52
|
+
* Constructor type.
|
|
53
|
+
*/
|
|
54
|
+
export type TypedConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> =
|
|
55
|
+
Constructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Typed abstract constructor, applicable to any constructor.
|
|
59
|
+
*
|
|
60
|
+
* @template TConstructor
|
|
61
|
+
* Constructor type.
|
|
62
|
+
*/
|
|
63
|
+
export type TypedAbstractConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> =
|
|
64
|
+
AbstractConstructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
|
|
65
|
+
|
|
17
66
|
/**
|
|
18
67
|
* Determine the fundamental promised type. This is stricter than `Awaited<Type>` in that it requires a {@linkcode
|
|
19
68
|
* Promise}.
|