Library API
    Preparing search index...

    Function byLkp

    • Groups an array of objects by a callback function, retaining only the last entry per group.

      Type Parameters

      Parameters

      • arr: T[]

        The array of objects to group

      • grpFn: GroupFn<T>

        The callback function returning the group key

      Returns Record<PropertyKey, T>

      A record containing the last object from each group

      const latest = byLkp(events, ev => ev.id);
      
    • Groups an array of objects by key fields, retaining only the last entry per group.

      Type Parameters

      Parameters

      • arr: T[]

        The array of objects to group

      • key1: keyof T
      • ...keys: (keyof T)[]

        The sequence of object keys to group by

      Returns Record<PropertyKey, T>

      A record containing the last object from each group

      const latest = byLkp(events, 'type');
      
    • Groups an array of objects by a callback function, retaining only the last entry per group.

      Type Parameters

      Parameters

      • arr: T[]

        The array of objects to group

      • ...keys: (keyof T)[]

      Returns Record<keyof T, T>

      A record containing the last object from each group

      const latest = byLkp(events, ev => ev.id);