builder
builder copied to clipboard
Refactor: Remove toLowerCase from indexById on Bridge
It shouldn't really change anything and it should allow us to rewrite the indexById as
static indexById<T extends { id: string }>(
list: (T | undefined)[]
): Record<string, T> {
return this.indexBy(list, 'id')
}
static indexBy<T extends Record<K, string>, K extends string>(
list: (T | undefined)[],
prop: K
): Record<string, T> {
return list.reduce((obj, result) => {
if (result) {
const key = result[prop]
obj[key as string] = result
}
return obj
}, {} as Record<string, T>)
}