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

    Function findArrayItemByKey

    • Returns the first item where item[key] === value, or undefined if not found.

      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 T | undefined

      findArrayItemByKey([{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }], "id", 2)
      // => { id: 2, name: "Bob" }