Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of _.compact #1209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MrAndrewKirillov
Copy link

馃摑 Description

馃幆 Relevant issues

issue:747

馃拵 Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

馃弫 Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

Copy link
Member

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if you add a compact method to utils (similar to other lodash compatible functions) and use it in the codes.

@MrDroid1
Copy link
Contributor

@icebob I think creating method for compact is overhead, cause function too small and we haven't to use lodash style. May you describe your point of it, it's easy to add method, but I realy don't understend point of it.

@icebob
Copy link
Member

icebob commented May 21, 2023

The lodash compact as the input is not array, or null or undefined. So when I'm using I don't care to check the parameter before add it to function because it will handle and always returns an array. The current solution doesn't handle it, but in a utils function we can do this check as well.

image

@MrDroid1
Copy link
Contributor

The lodash compact as the input is not array, or null or undefined.

Yeah, but this behavior not expected and lodash documentation says you have to use array as a parameter to remove falsy values. I think we should not rely on the behavior of the method, but should proceed from the needs, that is, the method should remove falsy values from the array. fillter(Boolean) do that, remove falsy values from array.

So when I'm using I don't care to check the parameter before add it to function because it will handle and always returns an array

In my opinion, it's a bad idea to rely on a single method and the best solution would be to use monosemantic values and methods using monosemantic values and responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants