-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(compat): Implement compat/pickBy #950
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
* const result = pickBy(obj, shouldPick); | ||
* // result will be { b: 'pick' } | ||
*/ | ||
export function pickBy<T extends Record<string, any>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
If you could add small fix here it would be great.
Function doesn't warn you if you pass null as obj, and if you do so, it will crash :)
however, lodash pickBy in that case returns {}
you can look here:
https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13582
Please add same here, or some warning that obj can't be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestion! I fixed this problem. Would you check it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thank you very much)
Maybe add some tests for it? I'm not sure.
And wait for approval from someone from repo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I will add some tests :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your help! Moved some test cases from lodash.
I added the
pickBy
function to compat, which behaviors similar to Lodash'spickBy
:the second param of the function is optional.
Thanks to: #946