makeLookup: Allow for key of zero
This commit is contained in:
parent
a769402c0c
commit
12c44d40a8
6 changed files with 34 additions and 3 deletions
|
@ -6,7 +6,7 @@ export function makeLookup<T>(
|
|||
key: keyof T
|
||||
): Record<string, T> {
|
||||
return (items || []).reduce((lookup, item) => {
|
||||
if (item && item[key]) {
|
||||
if (item !== undefined && item[key] !== undefined) {
|
||||
// The force cast is necessary if we want the keyof T above, and the flexibility
|
||||
// to pass anything in. And of course we're modifying a parameter!
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue