@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function arrayIncludes

    • Typed Array.prototype.includes — narrows the type of value to T[number] when returning true.

      Type Parameters

      • const T extends readonly unknown[]

      Parameters

      • array: T

        The array to search.

      • value: unknown

        The value to look for.

      Returns value is T[number]

      const roles = ["admin", "user"] as const
      arrayIncludes(roles, "admin") // => true, value typed as "admin" | "user"
      arrayIncludes(roles, "guest") // => false