@laserware/arcade
    Preparing search index...

    Function keyBy

    • Converts a collection of items to keyed by the specified field name.

      Type Parameters

      • T

        Type of item in the specified items array.

      Parameters

      • items: T[]

        Array of objects.

      • field: string

        Field to key by.

      Returns Dict<T>

      Object with key of the field name and value of the entry that corresponds to field.

      keyBy(
      { id: "a", value: 1 },
      { id: "b", value: 2 },
      "id",
      );
      // { a: { id: "a", value: 1 }, b: { id: "b", value: 2 } }