keyBy (Functional Programming) es-toolkit
Creates a function that builds an object keyed by each value. Use it with pipe.
Info
Usage
keyBy calls getKey for each value in the piped array and returns an object whose keys are the returned keys and whose values are the original items. Later values overwrite earlier values with the same key.
Parameters
getKey(item: T) => Krequired
The function that returns the key for each value.
Returns
A function that maps a readonly T[] to an object keyed by getKey.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.