Function filterToEnumValues

  • Filters the input array to all valid values from the given enum.

    Type Parameters

    Parameters

    • inputs: readonly unknown[]
    • checkEnum: T

    Returns T[keyof T][]

    A new array (does not mutate).

    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]`