@myparcel/ts-utils
Advanced tools
Comparing version 1.9.0 to 1.10.0
@@ -23,2 +23,14 @@ /** | ||
/** | ||
* Return a new record only with the keys whose values are assignable to the given type. If no keys are assignable to the given type, the resulting record must be empty. | ||
*/ | ||
type ExtractRecord<T, U> = { | ||
[K in keyof T as T[K] extends U ? K : never]: T[K]; | ||
}; | ||
/** | ||
* Extracts the keys of a record whose values are assignable to the given type. | ||
*/ | ||
type ExtractRecordKeys<T extends Record<any, any>, U> = keyof ExtractRecord<T, U>; | ||
type MakeOptional<T, K extends string | keyof T> = K extends keyof T ? Omit<T, K> & Partial<Pick<T, K>> : T; | ||
@@ -107,2 +119,2 @@ | ||
export { ArrayWithOneOrMore, MakeOptional, OneOrMore, PromiseOr, ReadonlyOr, RecursivePartial, RecursiveRequired, Replace, RequireOnly, ResolvePromise, ReverseMap, asyncEvery, asyncSome, isEnumValue, isInArray, isOfType, isUndefined, objectIsEqual, partitionArray, removePropertiesWith, toArray }; | ||
export { ArrayWithOneOrMore, ExtractRecord, ExtractRecordKeys, MakeOptional, OneOrMore, PromiseOr, ReadonlyOr, RecursivePartial, RecursiveRequired, Replace, RequireOnly, ResolvePromise, ReverseMap, asyncEvery, asyncSome, isEnumValue, isInArray, isOfType, isUndefined, objectIsEqual, partitionArray, removePropertiesWith, toArray }; |
{ | ||
"name": "@myparcel/ts-utils", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "TypeScript utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
13289
276