ts-gems 2.3.0 → 2.4.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/lib/deep-modify.d.ts +3 -3
- package/lib/deep-omit.d.ts +3 -3
- package/lib/deep-pick.d.ts +3 -3
- package/lib/{keys.ts → keys.d.ts} +21 -21
- package/lib/omit.d.ts +7 -1
- package/lib/pick.d.ts +7 -1
- package/package.json +6 -6
package/lib/deep-modify.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Builtin} from './common';
|
|
2
|
-
import {IfTuple} from './type-check';
|
|
3
|
-
import {OptionalKeys} from './keys';
|
|
1
|
+
import { Builtin } from './common';
|
|
2
|
+
import { IfTuple } from './type-check';
|
|
3
|
+
import { OptionalKeys } from './keys';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Partial but deeply
|
package/lib/deep-omit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Builtin} from './common';
|
|
2
|
-
import {IfTuple} from './type-check';
|
|
3
|
-
import {JsonKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, WritableKeys} from './keys';
|
|
1
|
+
import { Builtin } from './common';
|
|
2
|
+
import { IfTuple } from './type-check';
|
|
3
|
+
import { JsonKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, WritableKeys } from './keys';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Omit all optional properties in T deeply
|
package/lib/deep-pick.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Builtin} from './common';
|
|
2
|
-
import {IfClass, IfTuple} from './type-check';
|
|
3
|
-
import {JsonKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, WritableKeys} from './keys';
|
|
1
|
+
import { Builtin } from './common';
|
|
2
|
+
import { IfClass, IfTuple } from './type-check';
|
|
3
|
+
import { JsonKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, WritableKeys } from './keys';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Pick all optional properties in T deeply
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IfEquals, IfCompatible, IfUndefined, IfAny, IfJson} from './type-check';
|
|
1
|
+
import { IfEquals, IfCompatible, IfUndefined, IfAny, IfJson } from './type-check';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* KeyOf
|
|
@@ -17,9 +17,9 @@ export type ValuesOf<T> = T[keyof T];
|
|
|
17
17
|
* @desc Returns required keys of an object
|
|
18
18
|
*/
|
|
19
19
|
export type RequiredKeys<T> = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
[K in keyof T]-?: IfUndefined<T[K]> extends true
|
|
21
|
+
? never
|
|
22
|
+
: T extends { [K1 in K]: any } ? K : never
|
|
23
23
|
}[keyof T];
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -27,9 +27,9 @@ export type RequiredKeys<T> = {
|
|
|
27
27
|
* @desc Returns optional keys of an object
|
|
28
28
|
*/
|
|
29
29
|
export type OptionalKeys<T> = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
[K in keyof T]-?: IfUndefined<T[K]> extends true
|
|
31
|
+
? never
|
|
32
|
+
: T extends { [K1 in K]: any } ? never : K
|
|
33
33
|
}[keyof T];
|
|
34
34
|
|
|
35
35
|
|
|
@@ -37,7 +37,7 @@ export type OptionalKeys<T> = {
|
|
|
37
37
|
* @desc Returns readonly keys of an object
|
|
38
38
|
*/
|
|
39
39
|
export type ReadonlyKeys<T> = {
|
|
40
|
-
|
|
40
|
+
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, never, K>
|
|
41
41
|
}[keyof T];
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -51,12 +51,12 @@ export type NonFunctionKeys<T> = Exclude<keyof T, FunctionKeys<T>>;
|
|
|
51
51
|
*/
|
|
52
52
|
export type JsonKeys<T> = _JsonKeys<T>;
|
|
53
53
|
type _JsonKeys<T, J = Required<T>> = ValuesOf<{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
[K in keyof J]: K extends symbol ? never
|
|
55
|
+
: IfUndefined<J[K]> extends true
|
|
56
|
+
? never
|
|
57
|
+
: IfJson<J[K]> extends true
|
|
58
|
+
? K
|
|
59
|
+
: never
|
|
60
60
|
|
|
61
61
|
}>;
|
|
62
62
|
|
|
@@ -70,30 +70,30 @@ export type WritableKeys<T> = Exclude<keyof T, ReadonlyKeys<T>>;
|
|
|
70
70
|
* @desc Returns writable json keys of an object
|
|
71
71
|
*/
|
|
72
72
|
export type WritableJsonKeys<T> = Extract<{
|
|
73
|
-
|
|
73
|
+
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, K, never>
|
|
74
74
|
}[keyof T], JsonKeys<T>>;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* @desc Returns Function keys of an object
|
|
78
78
|
*/
|
|
79
79
|
export type FunctionKeys<T> = ValuesOf<{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
[K in keyof T]-?: IfUndefined<T[K]> extends false ?
|
|
81
|
+
IfAny<T[K]> extends false ?
|
|
82
|
+
T[K] extends Function ? K
|
|
83
|
+
: never : never : never;
|
|
84
84
|
}>;
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* @desc Returns keys that match given type
|
|
88
88
|
*/
|
|
89
89
|
export type KeysCompatible<T, U> = ValuesOf<{
|
|
90
|
-
|
|
90
|
+
[K in keyof T]-?: IfCompatible<T[K], U, K, never>;
|
|
91
91
|
}>;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* @desc Returns keys that equals given type
|
|
95
95
|
*/
|
|
96
96
|
export type KeysEquals<T, U> = ValuesOf<{
|
|
97
|
-
|
|
97
|
+
[K in keyof T]-?: IfEquals<T[K], U, K, never>;
|
|
98
98
|
}>;
|
|
99
99
|
|
package/lib/omit.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
JsonKeys,
|
|
3
|
+
OptionalKeys,
|
|
4
|
+
ReadonlyKeys,
|
|
5
|
+
RequiredKeys,
|
|
6
|
+
WritableKeys
|
|
7
|
+
} from './keys';
|
|
2
8
|
|
|
3
9
|
export type StrictOmit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
4
10
|
|
package/lib/pick.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lodash",
|
|
13
13
|
"underscore"
|
|
14
14
|
],
|
|
15
|
-
"version": "2.
|
|
15
|
+
"version": "2.4.1",
|
|
16
16
|
"types": "lib/index.d.ts",
|
|
17
17
|
"main": "lib/index.js",
|
|
18
18
|
"module": "lib/index.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"lib/"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/jest": "^29.
|
|
36
|
-
"eslint": "^8.
|
|
37
|
-
"jest": "^29.
|
|
38
|
-
"ts-jest": "^29.
|
|
39
|
-
"typescript": "^
|
|
35
|
+
"@types/jest": "^29.5.3",
|
|
36
|
+
"eslint": "^8.45.0",
|
|
37
|
+
"jest": "^29.6.1",
|
|
38
|
+
"ts-jest": "^29.1.1",
|
|
39
|
+
"typescript": "^5.1.6"
|
|
40
40
|
}
|
|
41
41
|
}
|