-
Notifications
You must be signed in to change notification settings - Fork 633
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(collections): Returns an array excluding single given value #1074
Conversation
…SameValueZero for equality comparisons
…Labs/deno_std into feat-collection-without
Please add test cases when |
BTW this covers both |
I would personally prefer to distingush @getspooky would it be ok for you to split this into two functions? |
It might make sense to build a Something like: const valuesToExclude = new Set(values)
return array.filter(it => !valuesToExclude.has(it)) |
While they do the same task on an abstract level, a simple As all the functions in this module are pretty low level and attract usage in other algorithms, we should emphasize even small-ish performance gains. We have done that for all other functions in this module to this point. I would also challenge the assumption that both functions are the same in the mind of users - removing a single element and removing an arbitrarily long list of elenents can be quite different use cases and happen in different frequencies. |
…ead of multi values
3fa22d2
to
2e285cb
Compare
@getspooky Thanks for updating! The implementation looks good to me now. @LionC return array.filter((element) => value !== element); I'm now skeptical about the benefit of providing this function as part of |
I would recommend against implementing this function. An abstraction of a one-liner is not necessary imo. Using |
As stated several times, I do not see the harm in having such a function, while there is gain in it for some people, even if that does not include everyone. Other libraries have choosen to include it even though they have I feel like discussions like this boil down to coding style (how much abstraction / renaming do you like) a lot. We should keep in mind that |
@kt3k I think we should try to get a call on this, otherwise this PR will stand still forever. I personally do not see the harm in having a clearly named function doing a common useful thing with a concise API. Also, this(general) or this(specific) SO question and the (sometimes horrible) accepted/upvoted answers make me think that there is value in having a clearly named function with an optimal implementation... |
@LionC And many collaborators (Luca, Nayeem, Divy,...) are strongly against adding 'too trivial' items into std/collections (and we already retracted many items in earlier iteration because of the triviality of them). I'm afraid this one typically falls into that category. |
Talked a little bit with @LionC, but we're closing this particular one (mainly because of the triviality). @getspooky Thank you for working on this anyways. |
Returns an array excluding all given values
Example:
Discussion
Please see #1065