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

    Function hasArrayItemByKey

    • Returns true if the array contains an item where item[key] === value.

      Type Parameters

      • T
      • K extends string | number | symbol

      Parameters

      • array: readonly T[]

        The array to search.

      • key: K

        The key to match on.

      • value: T[K]

        The value to match.

      Returns boolean

      hasArrayItemByKey([{ id: 1 }, { id: 2 }], "id", 2)  // => true
      hasArrayItemByKey([{ id: 1 }, { id: 2 }], "id", 99) // => false