helpertypes
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -0,1 +1,10 @@ | ||
## [0.0.12](https://github.com/wessberg/helpertypes/compare/v0.0.11...v0.0.12) (2021-09-15) | ||
### Features | ||
* add additional helper types ([7a6eb8e](https://github.com/wessberg/helpertypes/commit/7a6eb8ed4b9aced393a3825880f6a93dc3464c06)) | ||
## [0.0.11](https://github.com/wessberg/helpertypes/compare/v0.0.10...v0.0.11) (2021-09-06) | ||
@@ -2,0 +11,0 @@ |
@@ -37,2 +37,5 @@ /** | ||
}[keyof T]>; | ||
export declare type PickMembersOfNotOfType<T, Type> = Pick<T, { | ||
[Key in keyof T]: T[Key] extends Type ? never : T[Key] extends Type | undefined ? never : Key; | ||
}[keyof T]>; | ||
/** | ||
@@ -84,2 +87,16 @@ * Builds up a lookup path into a record via tuple elements. For example, for the record `{ a: {b: {c: string}}}`, a valid value could be `["a", "b", "c"]` | ||
/** | ||
* A variant of `SplitRecord` that includes all similar keys. | ||
* See the documentation for `SimilarObjectKeys` for more details. | ||
*/ | ||
export declare type SplitRecordWithSimilarKeys<T, U = T> = Exclude<{ | ||
[Key in keyof T]: Key extends keyof U ? SimilarObjectKeys<T, Key & string> : never; | ||
}[keyof T], undefined>; | ||
/** | ||
* Selects only the properties from an object for which the keys include the substring(s) given in U. | ||
* For example, for the object {foo: 1, fooBar: 2, barFoo: 3, baz: 4}, a value of "foo" for U will return an object with only the keys "foo", "fooBar", and "barFoo" | ||
*/ | ||
export declare type SimilarObjectKeys<T, U extends keyof T & string> = PickMembersOfNotOfType<{ | ||
[TKey in keyof T]: TKey extends U ? T[TKey] : TKey extends `${infer _Prefix}${Capitalize<U>}` ? T[TKey] | undefined : TKey extends `${infer _Prefix}${U}` ? T[TKey] | undefined : TKey extends `${U}${infer _Suffix}` ? T[TKey] | undefined : never; | ||
}, never>; | ||
/** | ||
* An arbitrary Function that takes any amount of arguments and returns anything | ||
@@ -127,2 +144,10 @@ */ | ||
}; | ||
export declare type PrefixObjectKeys<T, Prefix extends string, EnsureCamelCase = false> = { | ||
[Key in keyof T as SuffixKey<Key & string, Prefix, EnsureCamelCase>]: T[Key]; | ||
}; | ||
export declare type SuffixObjectKeys<T, Suffix extends string, EnsureCamelCase = false> = { | ||
[Key in keyof T as PrefixKey<Key & string, Suffix, EnsureCamelCase>]: T[Key]; | ||
}; | ||
export declare type PrefixKey<T extends string, Prefix extends string, EnsureCamelCase = false> = `${Prefix}${EnsureCamelCase extends true ? Capitalize<T> : T}`; | ||
export declare type SuffixKey<T extends string, Suffix extends string, EnsureCamelCase = false> = `${T}${EnsureCamelCase extends true ? Capitalize<Suffix> : Suffix}`; | ||
export declare type Prev<T extends number> = [ | ||
@@ -129,0 +154,0 @@ -1, |
{ | ||
"name": "helpertypes", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "A collection of TypeScript helper types", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31641
364