Comparing version 0.1.2 to 0.1.3
@@ -5,30 +5,40 @@ import {Primitive} from './types'; | ||
export type KeyOfValueWithType<T extends object, TValue> = { | ||
[K in keyof T]: T[K] extends TValue ? K : never | ||
}[keyof T]; | ||
export type KeyOfValueWithType<TObject extends object, TValue> = { | ||
[K in keyof TObject]: TObject[K] extends TValue ? K : never | ||
}[keyof TObject]; | ||
export type KeyOfValueNotWithType<T extends object, TValue> = { | ||
[K in keyof T]: T[K] extends TValue ? never : K | ||
}[keyof T]; | ||
export type KeyOfValueNotWithType<TObject extends object, TValue> = { | ||
[K in keyof TObject]: TObject[K] extends TValue ? never : K | ||
}[keyof TObject]; | ||
// Extract values | ||
export type ValueWithType<TObject extends object, TValue> = { | ||
[K in keyof TObject]: TObject[K] extends TValue ? TObject[K] : never | ||
}[keyof TObject]; | ||
// Keep or omit values by keys | ||
export type KeepValueOfKey< | ||
T extends object, | ||
TKey extends keyof T | ||
> = T extends object ? Pick<T, Extract<keyof T, TKey>> : never; | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = TObject extends object | ||
? Pick<TObject, Extract<keyof TObject, TKey>> | ||
: never; | ||
export type OmitValueOfKey< | ||
T extends object, | ||
TKey extends keyof T | ||
> = T extends object ? Pick<T, Exclude<keyof T, TKey>> : never; | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
> = TObject extends object | ||
? Pick<TObject, Exclude<keyof TObject, TKey>> | ||
: never; | ||
// Keep or omit values with given type | ||
export type KeepValueWithType<T extends object, TValue> = { | ||
[K in KeyOfValueWithType<T, TValue>]: T[K] | ||
export type KeepValueWithType<TObject extends object, TValue> = { | ||
[K in KeyOfValueWithType<TObject, TValue>]: TObject[K] | ||
}; | ||
export type OmitValueWithType<T extends object, TValue> = { | ||
[K in KeyOfValueNotWithType<T, TValue>]: T[K] | ||
export type OmitValueWithType<TObject extends object, TValue> = { | ||
[K in KeyOfValueNotWithType<TObject, TValue>]: TObject[K] | ||
}; | ||
@@ -35,0 +45,0 @@ |
{ | ||
"name": "tslang", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "TypeScript Language Type Utilities.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
3140
61