utilium 2.5.8 → 2.6.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/dist/objects.d.ts +17 -0
- package/package.json +1 -1
package/dist/objects.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type { Expand, UnionToTuple } from './types.js';
|
|
|
2
2
|
export declare function filterObject<O extends object, R extends object>(object: O, predicate: (key: keyof O, value: O[keyof O]) => boolean): R;
|
|
3
3
|
export declare function pick<T extends object, K extends keyof T>(object: T, ...keys: readonly K[]): Pick<T, K>;
|
|
4
4
|
export declare function pick<T extends object, K extends keyof T>(object: T, ...keys: readonly (readonly K[])[]): Pick<T, K>;
|
|
5
|
+
/** @see https://github.com/microsoft/TypeScript/issues/49656 */
|
|
6
|
+
export type Omit<T, K extends PropertyKey> = {
|
|
7
|
+
[P in keyof T as Exclude<P, K>]: T[P];
|
|
8
|
+
};
|
|
5
9
|
export declare function omit<T extends object, K extends keyof T>(object: T, ...keys: readonly K[]): Omit<T, K>;
|
|
6
10
|
export declare function omit<T extends object, K extends keyof T>(object: T, ...keys: readonly (readonly K[])[]): Omit<T, K>;
|
|
7
11
|
export declare function assignWithDefaults<To extends Record<keyof any, any>, From extends Partial<To>>(to: To, from: From, defaults?: Partial<To>): void;
|
|
@@ -65,6 +69,18 @@ export declare function bindFunctions<T extends object, This = any>(fns: T, this
|
|
|
65
69
|
export type Mutable<T> = {
|
|
66
70
|
-readonly [P in keyof T]: T[P];
|
|
67
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Makes all properties in T readonly recursively
|
|
74
|
+
*/
|
|
75
|
+
export type ReadonlyRecursive<T> = T extends object ? {
|
|
76
|
+
readonly [K in keyof T]: ReadonlyRecursive<T[K]>;
|
|
77
|
+
} : T;
|
|
78
|
+
/**
|
|
79
|
+
* Makes all properties in T mutable recursively
|
|
80
|
+
*/
|
|
81
|
+
export type MutableRecursive<T> = T extends object ? {
|
|
82
|
+
-readonly [P in keyof T]: MutableRecursive<T[P]>;
|
|
83
|
+
} : T;
|
|
68
84
|
/**
|
|
69
85
|
* Makes properties with keys assignable to K in T required
|
|
70
86
|
* @see https://stackoverflow.com/a/69328045/17637456
|
|
@@ -132,3 +148,4 @@ export type Never<T> = {
|
|
|
132
148
|
* All of the properties in T or none of them
|
|
133
149
|
*/
|
|
134
150
|
export type AllOrNone<T> = T | Never<T>;
|
|
151
|
+
export type Filter<Key, Arr extends readonly any[]> = Arr extends readonly [infer L, ...infer R] ? L extends Key ? Filter<Key, R> : [L, ...Filter<Key, R>] : [];
|