@ptolemy2002/ts-utils 2.0.1 → 2.2.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/README.md +7 -0
- package/dist/index.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,10 @@ This type returns a union of all the keys in `T` that have a value assignable to
|
|
|
33
33
|
### PartialBy<T, K extends keyof T>
|
|
34
34
|
This type returns a type that is the same as `T` except that the keys in `K` are optional.
|
|
35
35
|
|
|
36
|
+
### Rename<T, K extends keyof T, N extends string>
|
|
37
|
+
This type returns a type that is the same as `T` except that the key `K` is renamed to `N`.
|
|
38
|
+
|
|
39
|
+
|
|
36
40
|
### ValueCondition<T>
|
|
37
41
|
This type allows the user to specify a condition for matching a subset of type `T`. It can be one of the following:
|
|
38
42
|
- A value of type `T`
|
|
@@ -54,6 +58,9 @@ type AdvancedConditionConstructorArgs<T> = {
|
|
|
54
58
|
};
|
|
55
59
|
```
|
|
56
60
|
|
|
61
|
+
### ValuesIntersection<T>
|
|
62
|
+
This type returns an intersection of all the possible values in an object of type `T`.
|
|
63
|
+
|
|
57
64
|
## Classes
|
|
58
65
|
The following classes are available in the library:
|
|
59
66
|
|
package/dist/index.d.ts
CHANGED
|
@@ -38,3 +38,9 @@ export declare class AdvancedCondition<T> {
|
|
|
38
38
|
export type ValueCondition<T> = AdvancedCondition<T> | T | ((v: T) => boolean) | (ValueCondition<T> | false)[];
|
|
39
39
|
export type OptionalValueCondition<T> = ValueCondition<T> | null;
|
|
40
40
|
export declare function valueConditionMatches<T>(value: T, condition: OptionalValueCondition<T>): boolean;
|
|
41
|
+
export type Rename<T, K extends keyof T, N extends string> = Pick<T, Exclude<keyof T, K>> & {
|
|
42
|
+
[P in N]: T[K];
|
|
43
|
+
};
|
|
44
|
+
export type ValuesIntersection<T> = ValueOf<{
|
|
45
|
+
[K in keyof T]: (x: T[K]) => void;
|
|
46
|
+
}> extends (x: infer I) => void ? I : never;
|