UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

33 lines (32 loc) 788 B
import { type EnumBaseType } from '@augment-vir/core'; /** * Filters the input array to all valid values from the given enum. * * @category Array * @category Enum * @category Package : @augment-vir/common * @example * * ```ts * enum MyEnum { * A = 'a', * B = 'b', * } * * const result = filterToEnumValues( * [ * 1, * 2, * 3, * 'a', * 'b', * MyEnum.A, * ], * MyEnum, * ); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]` * ``` * * @returns A new array (does not mutate). * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function filterToEnumValues<const T extends EnumBaseType>(inputs: ReadonlyArray<unknown>, checkEnum: T): T[keyof T][];