toRecord
Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
Import
Usage
Parameters
array
T[]
The array of objects to convert to a record
selector
K
The key used to select the property that will become the record’s key
fn
(item: T) => V
The function that transforms each item in the array into the record’s value
Returns
Record<T[K], V>
The resulting record object