rambdax
Version:
Extended version of Rambda - a lightweight, faster alternative to Ramda
20 lines (18 loc) • 432 B
text/typescript
import {Union} from './Union'
import {Is} from '../Any/Is'
import {Match} from '../Any/_Internal'
/**
* Extract the part of `U` that matches `M`
* @param U to extract from
* @param M to select with
* @returns [[Union]]
* @example
* ```ts
* ```
*/
export type Select<U extends Union, M extends any, match extends Match = 'default'> =
U extends unknown
? Is<U, M, match> extends 1
? U
: never
: never