@jonahsnider/util

    Function enumHas

    • Check whether a given value is a member value of an enum.

      Time complexity: O(1) if Enum has been seen before. Otherwise, O(n) where n is the number of enum values.

      Space complexity: O(1) if Enum has been seen before. Otherwise, O(n) where n is the number of unique enum values.

      Type Parameters

      Parameters

      • Enum: Readonly<Record<string | number, T>>

        The enum to use as the source of member values

      • value: unknown

        The value to check

      Returns value is T

      Whether value is a member value of Enum

      Enum

      enum Enum {
      A,
      B,
      }

      enumHas(Enum, 0); // true
      enumHas(Enum, 2); // false
    MMNEPVFCICPMFPCPTTAAATR