@trezor/type-utils
Advanced tools
Comparing version 1.1.1-beta.1 to 1.1.1-beta.2
{ | ||
"name": "@trezor/type-utils", | ||
"version": "1.1.1-beta.1", | ||
"version": "1.1.1-beta.2", | ||
"license": "See LICENSE.md in repo root", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -61,15 +61,1 @@ // make key required | ||
export type DefinedUnionMember<T> = T extends string ? T : never; | ||
/** | ||
* Type-guard if a value is a subset of an array. | ||
* Useful to narrow down a union type `value` to a subset of the union (typeof `arr`). | ||
* | ||
* Example: | ||
* type Variant = 'a' | 'b' | 'c' | 'd'; | ||
* const skippedVariants = ['a', 'b'] satisfies Variant[]; | ||
* if(isArrayMember(variant, skippedVariants)) // variant is 'a' | 'b', else 'c' | 'd' | ||
*/ | ||
export const isArrayMember = <Value extends string, Subset extends Value>( | ||
value: Value, | ||
arr: Subset[], | ||
): value is Subset => arr.some(v => v === value); |
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
2895
49