Conversation
|
By analyzing the blame information on this pull request, we identified @pixelastic to be a potential reviewer |
|
@pixelastic What do you think about that? |
src/lib/utils.js
Outdated
| throw new Error(`[groupBy]: Object has no key ${property}`); | ||
| } | ||
| let key = item[property]; | ||
| let key = item[property] && item[property].toLowerCase(); |
There was a problem hiding this comment.
Why the &&?
let key = item[property].toLowerCase(); should be enough
There was a problem hiding this comment.
I think playground was failing otherwise
There was a problem hiding this comment.
Because item[property] can be null
There was a problem hiding this comment.
Then we should update the if a few line above, where it is testing if it's undefined to also test null
There was a problem hiding this comment.
Hmmm, I think it's fine to group hits sharing the null value together. It happens if - for a unknown reason - you don't have lvl1 for instance.
I can make the test more explicit if you want.
There was a problem hiding this comment.
I would make the code more explicit then.
let key = item[property];
if (key.toLowerCase) {
let = key.toLowerCase();
}Still not perfect (key can be an object with a toLowerCase field that is not a function...) but it expresses the intent of what you want to do more easily.
Fix #85